Aidurber / obsidian-plugin-dynamic-toc

An Obsidian plugin for creating Tables of Contents that stay updated with your document
MIT License
269 stars 41 forks source link

Incorrect formatting when heading is an internal link with a custom name #28

Closed SebMoore closed 2 years ago

SebMoore commented 2 years ago

Obsidian provides support for creating internal links and displaying text for this link that is different to the name of the note you are linking to. For example: [[Example Link]] renders as Example Link, and links to the file "Example Link" [[Example Link|Alt Text]] renders as Alt Text, but links to the same file, "Example Link". This is useful for creating readable links where the actual note file may have a long and complex name. Unfortunately, when I create a heading entitled [[Example Link|Alt Text]], dynamic-toc renders it as Alt Text|Example Link|Alt Text which kind of defeats the point of using these kind of internal links in the first place. Here's a screenshot to show what I mean: dynamic-toc-issue Apart from this, the plugin works amazingly, so hats off to Aidurber for this great work. Any resolution would be greatly appreciated!

Aidurber commented 2 years ago

Thank you for the really detailed bug report, it really helps me understand what's gone wrong and how to reproduce it. I've got a PR for this, I had to rewrite a bunch of stuff to make this work. I'll try and get it released today.

Aidurber commented 2 years ago

@SebMoore I've released 0.0.19, you can try the new extractor by going into settings and turning on "New heading extraction"

CleanShot 2021-12-21 at 14 23 31@2x

Do you want to give it a go and let me know how it goes?

SebMoore commented 2 years ago

@Aidurber it works perfectly - really appreciate all the effort you put into this. Cheers!

Aidurber commented 2 years ago

Awesome @SebMoore, thanks for helping me test this. I'll ship it to every one 🙌