microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.43k stars 28.62k forks source link

Markdown preview always renders anchors as links #108166

Closed brunnerh closed 3 years ago

brunnerh commented 3 years ago

Issue Type: Bug

Contents of anchors without href should just render normally.

Example:

image

As text:

...

<a id="custom-anchor">This is an anchor</a>

...

[This is a link](#custom-anchor)

VS Code version: Code 1.49.3 (2af051012b66169dde0c4dfae3f5ef48f787ff69, 2020-10-02T17:57:01.595Z) OS version: Windows_NT x64 10.0.17134

mjbvz commented 3 years ago

The markdown preview uses Markdown-it, which also has this behavior: https://markdown-it.github.io/#md3=%7B%22source%22%3A%22%3Ca%20id%3D%5C%22custom-anchor%5C%22%3EThis%20is%20an%20anchor%3C%2Fa%3E%5Cn%22%2C%22defaults%22%3A%7B%22html%22%3Atrue%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22html%22%7D%7D

Please file an issue against Markdown-It if you feel this is a problem

brunnerh commented 3 years ago

@mjbvz It is not an issue with markdown-it, that only generates HTML, not CSS. The presentation is part of the webview code. I can create a pull request to fix this.