Assuming that markup.goldmark.extensions.definitionList = true
(the default)…
This markdown:
term
: definition
is rendered to:
<dl>
<dt>term</dt>
<dd>definition</dd>
</dl>
but what I really, really want is:
<dl>
<dt id="term">term</dt>
<dd>definition</dd>
</dl>
where the id
attribute is automatically generated and, if necessary, incremented to prevent (or least mitigate) duplicate id’s on the page (the same way that we handle heading id
attributes).
While you can apply a markdown attribute to the description list, you cannot apply a markdown attribute to the term or definition.
You can obviously work around this by using heading elements instead of a description list, but (a) the description list seems a semantically better choice, and (b) the additional heading elements may pollute the TOC depending on configuration (endLevel
).
A couple of examples from our docs:
Description list: https://gohugo.io/functions/highlight/#options
Heading elements: https://gohugo.io/getting-started/configuration/#all-configuration-settings
I am guessing that we used heading elements in the second example in order to provide link targets.