yzane / vscode-markdown-pdf

Markdown converter for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=yzane.markdown-pdf
Other
1.01k stars 206 forks source link

Mismatch Between Markdown Link Text and HTML id Attributes #387

Open kennelvy opened 1 week ago

kennelvy commented 1 week ago

When creating a link in Markdown, if the link text contains underscores, the resulting HTML link may not work correctly. This is because the id of the target element in HTML may not include underscores, and the href in the link must match the id exactly.

Consider the following example in Markdown:

Link
[TITLE](<#title>)
[A_TITLE](<#a_title>)
[THIS_TITLE](<#this_title>)
[OTHER_TITLE](<#other_title>)

In the generated HTML:

<h4 id="title">TITLE</h4>
<h4 id="atitle">A_TITLE</h4>
<h4 id="thistitle">THIS_TITLE</h4>
<h4 id="othertitle">OTHER_TITLE</h4>

the id attributes of the headings do not contain underscores. As a result, Markdown links with underscores in the href, such as [A_TITLE](<#a_title>), won’t work because the id in HTML is written without underscores (e.g., id="atitle").