vscode-markdown
vscode-markdown copied to clipboard
TOC not recognized custom title id
Hello, thanks for great extension. But I have little issue about table of contents.
Problem
TOC not recognized custom title id in markdown
## Title 1 {#custom-title-id}
and created like this
[Title 1 {#custom-title-id}]{#title-1}
How to reproduce
[Title 1](#custom-title-id)
All suggestions are wellcome.
Thanks,
Thank you for your input.
{#custom-id}
looks like a pandoc's extension.
I'm afraid we will not support it until a good number of users request it.
By default (in github
mode), our latest dev build produces
## Title 1 {#custom-title-id}
- [Title 1 {#custom-title-id}](#title-1-custom-title-id)
It's different form your result. So I wonder ...
Are you also using other extensions like markdown-it-attrs?
Other extensions could interfere with our heading ID generation. That bug was fixed in #817
This is pretty old, but I'd like this feature as well.
It would also be nice to recognize html type anchor tags, ie:
# <a id='custom-title-id'></a>Title 1
would create: [Title 1](#custom-title-id)
instead of: - [<a id='custom-title-id'></a>Title 1](#title-1
Markdown does not work this way, although it can be what you see when rendering Markdown documents as HTML on a specific platform.
CommonMark does not care about the meaning of HTML, and asks implementations to pass HTML-like text as is. But web browsers process HTML according to WHATWG standards which are much different from CommonMark. Meanwhile, raw HTML is already a major cause of corrupted rendering results, and it's generally discouraged to have raw HTML in a Markdown document.
Last but not least, heading ID generation is heavily platform-dependent, which is why we have a "slugify mode" setting and plan to get a "document mode" setting.