huntertran / markdown-toc

Auto MarkdownTOC (Table Of Contents) plugin for Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=huntertran.auto-markdown-toc
MIT License
39 stars 25 forks source link

Allow stable links #32

Open pgroke-dt opened 4 years ago

pgroke-dt commented 4 years ago

IMO it's often useful to have stable links to sections of a document, even if the header text is changed (e.g. typo fixed or rephrased for improved clarity). So it would be great if this was possible.

I was thinking about maybe using the class attribute in the anchor to mark it as "user defined". When such an anchor is discovered, the name and id attributes should be parsed from it and used in the TOC, and the anchor should either be left in place unchanged or re-generated using the same class, name and id attributes.

Anchors not marked as "user defined" as well as missing anchors should be treated like they are currently, i.e. updated or inserted. Also the TOC text should be updated to match changed headers.