alanwalk / markdown-toc

MarkdownTOC(Table Of Contents) Plugin for Visual Studio Code.
MIT License
141 stars 111 forks source link

Invalid anchor links with identical headlines #37

Open janpio opened 6 years ago

janpio commented 6 years ago
# h1

<!-- TOC -->

- [h1](#h1)
    - [Headline](#headline)
    - [Different Headline](#different-headline)
    - [Headline](#headline-1)

<!-- /TOC -->

## Headline

text

## Different Headline

text

## Headline

text

The second "Headline" link doesn't work in the Preview.

I couldn't figure out what the actual correct anchor for that headline would be, or if it even also is #headline.

alanwalk commented 6 years ago

The default anchor mode is github.com, vscode's default preview is not same mode.

janpio commented 6 years ago

Meaning what exactly?

alanwalk commented 6 years ago

Hi, Markdown-TOC can't support vscode's preview. Because vscode use markdown-it & markdown-it-named-headers to render Markdown. I have no way to distinguish the same header with render result. I had create a issue to vscode. I'm sorry for it, thank you for your understanding.

source code link : https://github.com/Microsoft/vscode/blob/468dc867cdeb75bddc1e4fa965ea1df97e4782ea/extensions/markdown-language-features/src/markdownEngine.ts

image

mcornella commented 4 years ago

Tested in current VS Code: the preview now works the same way as github.com. This can be closed.