markdown-toc icon indicating copy to clipboard operation
markdown-toc copied to clipboard

Invalid anchor links with identical headlines

Open janpio opened this issue 7 years ago • 4 comments

# 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.

janpio avatar Oct 19 '17 16:10 janpio

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

alanwalk avatar Apr 09 '18 09:04 alanwalk

Meaning what exactly?

janpio avatar Apr 09 '18 11:04 janpio

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

alanwalk avatar Apr 10 '18 02:04 alanwalk

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

mcornella avatar Sep 23 '20 21:09 mcornella