IBM / marked-it

marked-it
MIT License
16 stars 24 forks source link

link definition is causing attribute to be associated with wrong element #7

Closed grant-g closed 2 months ago

grant-g commented 5 years ago
[key]: https://foo.com

# The release notes
{: #release-notes}

some short words
{: shortdesc}

For some reason the release-notes id is being associated with the paragraph below it instead of the header above it.

grant-g commented 5 years ago

marked doesn't generate tokens for link definitions, it just returns names+values. As a result the link definition characters aren't being accounted for, which throws off the attribute->element mappings. Best path may be to detect this case and generate place-holder tokens, but getting them placed correctly could be tricky.

grant-g commented 5 years ago

A better approach would probably be to identify the text ranges of all of these in the source text before passing to marked, and then adjusting the attribute->element mappings accordingly.

grant-g commented 2 months ago

Confirmed that this works as expected with the latest, likely due to changing the underlying md->HTML renderer off of marked. Closing Issue.