apple/swift-markdown

Allow adding `id` attributes to arbitrary elements

QuietMisdreavus opened this issue · 0 comments

Radar: rdar://97350693

The standard Markdown behavior is to add a link anchor (id attribute) to headings, based on the text of the heading. apple/swift-docc#345 is about customizing these heading anchors. However, in some situations you may want to add a link anchor somewhere that's not a heading - e.g. a figure with caption, a term-definition list item, etc.

Some prior art exists in MultiMarkdown, which allows you to add arbitrary attributes to a link or image, which can include an id attribute. This is restricted to links and images, but the syntax could be used as a jumping-off point, if it's going to be implemented in base Markdown.

I'm unsure about the ultimate syntax this should take - if we follow syntax like MultiMarkdown or PHP Markdown Extra, we'll likely need to patch swift-cmark for it. However, if we add a directive for it, it's possible that we could leave the implementation wholly here in Swift-Markdown.