如何链接到 Github 中另一个 Markdown 文件中的特定部分

问题描述 投票:0回答:1

我有一个关于链接到我的项目中不同 Markdown 文件中的特定部分的问题。

我正在管理一个包含多个 Markdown 文档的项目,并且想要创建从一个文件到另一个文件的特定部分(锚点)的直接链接。例如,我希望从 document1.md 链接到 document2.md 中的 #section2,但以下语法无法按预期工作:

document2.md 中的#section2

## <span id="ELB_concept">content</span>

文档1.md

<a href="path to #section2 within document2">content</a>

当我单击链接时,它会打开 document2.md,但不会滚动到#section2。 我该如何解决这个问题以使其正常工作?非常欢迎任何建议或解决方案。

github markdown
1个回答
0
投票

请使用这样的文件路径和部分:

path/to/document2.md#section2

在文档1.md中:

[Link to Section 2 in document2.md](path/to/document2.md#section2)

在 document2.md 中,您想要 #section2 的位置:

## Section 2
This is the content of Section 2.

当您单击 document1.md 中的链接时,它将打开并向下滚动到相关部分。

© www.soinside.com 2019 - 2024. All rights reserved.