-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bug: pending triageMaybe a bug, waiting for confirmationMaybe a bug, waiting for confirmation
Description
Describe the bug
Markdown 链接中以数字开头的锚点(我不确定是否还有其他情况也会有这个问题),编译后会被自动添加 _ 前缀。
In Markdown links, anchors (fragment identifiers) that start with a number (not sure if other cases are also affected) will automatically have an underscore _ prefixed after compilation.
Reproduction
markdown-examples.md:
## 1. Syntax Highlighting
### 1.1. HI 测试标题
[测试链接1](#11-hi-测试标题)
[测试链接2](api-examples.md#2-more)
[测试链接3](api-examples.md#final)
[测试链接4](api-examples.md#最后)
<a href="./api-examples#2-more">HTML 格式链接</a>
api-examples.md:
## 2. More
Check out the documentation for the [full list of runtime APIs](https://vitepress.dev/reference/runtime-api#usedata).
## Final
## 最后
编译后的 markdown-examples.html:
Generated markdown-examples.html:
<p><a href="#_11-hi-测试标题">测试链接1</a></p>
<p><a href="./api-examples#_2-more">测试链接2</a></p>
<p><a href="./api-examples#final">测试链接3</a></p>
<p><a href="./api-examples#最后">测试链接4</a></p>
<p><a href="./api-examples#2-more">HTML 格式链接</a></p>“测试链接1” 和 “测试链接2” 的原始锚点被篡改了(添加了 _ 前缀)。
The original anchors for “Test Link 1” and “Test Link 2” were altered (an underscore _ was added).
“测试链接3”、“测试链接4”、“HTML 格式链接” 没有问题(保持原值不变)。
“Test Link 3”, “Test Link 4”, and the HTML-formatted link are unaffected (the original values remain unchanged).
Expected behavior
“测试链接1” 和 “测试链接2” 的锚点不应被篡改。
The anchors for “Test Link 1” and “Test Link 2” should not be modified.
System Info
略 (omitted)
Additional context
No response
Validations
- Check if you're on the latest VitePress version.
- Follow our Code of Conduct
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Metadata
Metadata
Assignees
Labels
bug: pending triageMaybe a bug, waiting for confirmationMaybe a bug, waiting for confirmation