cmaas / markdown-it-table-of-contents

A table of contents plugin for Markdown-it
MIT License
99 stars 33 forks source link

Doesn't respect custom heading ids from markdown-it-attrs / no way to define custom ids #54

Closed cmaas closed 2 years ago

cmaas commented 3 years ago

I'm giving my headings custom ids via the plugin markdown-it-attrs so that they stay the same, even if I change the text. Helpful for evergreen-content like FAQs etc.:

# FAQ
## What does it cost? {#price}

Unfortunately, slugify() only receives the text content as parameter, not the id of the heading. So, there's no way to override this as far as I can see. Expected output: should use #price as link target. Actual output: #what-does-it-cost

I think the code that searches for heading tokens should also look for 'headings_open' and check if there is an id-attribute and use this as a slug.