johansatge / obsidian-automatic-table-of-contents

💠 An Obsidian plugin to create a table of contents in a note, that updates itself when the note changes
MIT License
128 stars 12 forks source link

Strip headings for readability / wikilinks compatibility #34

Closed johansatge closed 6 months ago

johansatge commented 6 months ago

The plugin uses wikilinks to generate a clickable table of contents (see in this PR why wiklinks and not markdown links) but wiklinks don't support formatting; this link for instance:

[[#some-anchor|Some **text** with <em>emphasis</em>]]

will render as:

Some **text** with <em>emphasis</em>

So let's strip markdown & HTML markup from headings when generating the TOC. So the text will lose its formatting, but be readable:

Some text with emphasis

And don't apply stripping if includeLinks: false