是否存在等价的markdown语法:
Take me to <a href="#pookie">pookie</a>
...
<a name="pookie">this is pookie</a>
是否存在等价的markdown语法:
Take me to <a href="#pookie">pookie</a>
...
<a name="pookie">this is pookie</a>
当前回答
对于在GitBook中寻找此问题解决方案的任何人。这就是我如何使它工作(在GitBook)。你需要显式地标记你的标题,像这样:
# My Anchored Heading {#my-anchor}
然后像这样链接到这个锚
[link to my anchored heading](#my-anchor)
解决方案和其他示例可以在这里找到:https://seadude.gitbooks.io/learn-gitbook/
其他回答
使用一个名字。在HTML 5中不需要使用id,它会在JavaScript中创建全局变量
参见HTML 5规范,5.9.8导航到片段标识符- id和name都被使用。
重要的是要知道大多数浏览器仍然将id转换为全局变量。这里有一个快速测试。使用名称可以避免创建全局变量和可能导致的任何冲突。
使用名称的示例:
Take me to [pookie](#pookie)
和目的锚点:
### <a name="pookie"></a>Some heading
使用最新的Markdown,你应该能够使用以下语法:
[] () {: name =‘anchorName}
这将创建以下HTML:
<a name=“anchorName”></a>
如果你想要锚点有文本,只需在方括号内添加锚点文本:
[文本](){:name = ' anchorName '}
虽然姗姗来迟,但我认为这个添加可能对使用rmarkdown的人有用。在rmarkdown中,有内置的文档头引用支持。
定义的任何头
# Header
可由
get me back to that [header](#header)
下面是一个最小的独立.rmd文件,它显示了这种行为。它可以编织成。pdf和。html。
---
title: "references in rmarkdown"
output:
html_document: default
pdf_document: default
---
# Header
Write some more text. Write some more text. Write some more text. Write some more text. Write some more text. Write some more text. Write some more text. Write some more text. Write some more text. Write some more text. Write some more text.
Go back to that [header](#header).
对于在GitBook中寻找此问题解决方案的任何人。这就是我如何使它工作(在GitBook)。你需要显式地标记你的标题,像这样:
# My Anchored Heading {#my-anchor}
然后像这样链接到这个锚
[link to my anchored heading](#my-anchor)
解决方案和其他示例可以在这里找到:https://seadude.gitbooks.io/learn-gitbook/
对于头部包含表情符号的情况,我将快速补充,在这种情况下,只需删除引用链接中的表情符号就更简单了。例如
# ⭐ Title 2
....
[Take me to title 2](#-title-2)
在某些情况下,由于一些奇怪的原因,这不起作用,例如在这里的设置中。这种情况下的解决方案是包括表情符号的整个代码。