Skip to content

Enable markdown attributes for dt elements #11566

Open
@jmooring

Description

This markdown:

term
: definition

is currently 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>

This would allow us to manually link to the term, which would be very useful on documentation sites, our documentation site in particular.

ID's should be assigned using the same logic as heading id's... use GitHub id format, and increment as needed to prevent duplicates on the same page (that means checking heading id's as well).

Other thoughts:

  • Should this have an on/off switch? I can't think of a reason to disable the functionality.
  • If we do this, at some point someone will want to override the id using a markdown attribute, like you can with headings. But we can't currently assign a markdown attribute to a list item, only to the list itself.
  • This could also be handled (sort of) with a markdown render hook (layouts/_default/_markup/render-dt.html), but you wouldn't have the ability to guarantee unique ids (the render hook would have no knowledge of other id's on the page).
  • At some point these could be added to the .Fragments map as well (perhaps useful for .Related).
  • You can use this link render hook hack, but the markdown isn't portable.

Reference: https://discourse.gohugo.io/t/automatically-add-id-attribute-to-dt-element/38191

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions