Skip to content

Instantly share code, notes, and snippets.

@waaaaRapy
Created June 6, 2016 10:00
Show Gist options
  • Save waaaaRapy/d9abf54d7db70c7c8d436ae29f07cbae to your computer and use it in GitHub Desktop.
Save waaaaRapy/d9abf54d7db70c7c8d436ae29f07cbae to your computer and use it in GitHub Desktop.
hugo definition-list shortcode
{{ $str := print .Inner }}
{{ $str := replace $str "<ul>" "<dl>"}}
{{ $str := replace $str "</ul>" "</dl>"}}
{{ $str := replace $str "<ol>\n<li>" "<dd>" }}
{{ $str := replace $str "</li>\n</ol>" "</dd>" }}
{{ $str := replace $str "<li>" "<dt>" }}
{{ $str := replace $str "</li>" "</dt>" }}
{{ markdownify $str }}
@waaaaRapy
Copy link
Author

Example:

{{% dd %}}
- Coffee
  1. Black hot drink
- Milk
  1. White cold drink
{{% /dd %}}

is converted to

<dl>
  <dt>Coffee</dt>
  <dd>Black hot drink</dd>
  <dt>Milk</dt>
  <dd>White cold drink</dd>
</dl>

which rendered as

Coffee
Black hot drink
Milk
White cold drink

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment