是否存在等价的markdown语法:

Take me to <a href="#pookie">pookie</a>

... 

<a name="pookie">this is pookie</a>

当前回答

在bitbucket.org上投票的解决方案行不通。相反,当使用标题(使用##)时,可以将它们作为锚点引用,将它们作为#markdown-header-my-header-name作为前缀,其中#markdown-header-是由渲染器生成的隐式前缀,其余是小写标题,用破折号代替空格。

例子

## My paragraph title

会产生这样的隐式锚

#markdown-header-my-paragraph-title

在每个锚引用之前的整个URL是可选的,即。

[Some text](#markdown-header-my-paragraph-title)

相当于

[Some text](https://bitbucket.org/some_project/some_page#markdown-header-my-paragraph-title) 

前提是它们在同一页上。

来源:https://bitbucket.org/tutorials/markdowndemo/overview(编辑这个.md文件的源代码,看看锚是如何制作的)。

其他回答

使用一个名字。在HTML 5中不需要使用id,它会在JavaScript中创建全局变量

参见HTML 5规范,5.9.8导航到片段标识符- id和name都被使用。

重要的是要知道大多数浏览器仍然将id转换为全局变量。这里有一个快速测试。使用名称可以避免创建全局变量和可能导致的任何冲突。

使用名称的示例:

Take me to [pookie](#pookie)

和目的锚点:

### <a name="pookie"></a>Some heading

在bitbucket.org上投票的解决方案行不通。相反,当使用标题(使用##)时,可以将它们作为锚点引用,将它们作为#markdown-header-my-header-name作为前缀,其中#markdown-header-是由渲染器生成的隐式前缀,其余是小写标题,用破折号代替空格。

例子

## My paragraph title

会产生这样的隐式锚

#markdown-header-my-paragraph-title

在每个锚引用之前的整个URL是可选的,即。

[Some text](#markdown-header-my-paragraph-title)

相当于

[Some text](https://bitbucket.org/some_project/some_page#markdown-header-my-paragraph-title) 

前提是它们在同一页上。

来源:https://bitbucket.org/tutorials/markdowndemo/overview(编辑这个.md文件的源代码,看看锚是如何制作的)。

正如我们所看到的(从答案中),这没有标准的方法;不同的降价处理器在提供这种可能性的降价扩展方面会有所不同。

使用pandoc,你可以得到你想要的:

Take me to [pookie](#pookie)

...

[this is pookie]{#pookie}

这给出了(通过pandoc-2.9.2.1):

<p>Take me to <a href="#pookie">pookie</a></p>
<p>…</p>
<p><span id="pookie">this is pookie</span></p>

我们也可以用一个锚id创建一个空span:

Take me to [pookie](#pookie)

...

this is pookie []{#pookie}

这将产生:

<p>Take me to <a href="#pookie">pookie</a></p>
<p>…</p>
<p>this is pookie <span id="pookie"></span></p>

除此之外,对于pandoc和大多数常见的markdown生成器,在每个报头中都有一个简单的自生成锚。(请参阅此处和其他答案,以方便地(自动)生成和引用此类锚。)

Markdown Anchor支持hashmark,因此在页面中链接到一个锚将简单地[Pookie](# Pookie)

在Gruber Markdown中实际上不支持生成锚,但在其他实现中支持,例如Markdown Extra。

在Markdown Extra中,锚点ID用{#pookie}附加到标题或子标题中。

Github调味Markdown在Git存储库页面(但不是在gist)自动生成在所有标题(h1, h2, h3等)上带有几个标记标记的锚,包括:

id = " user-content-HEADERTEXT " 类=“锚” href = " # HEADERTEXT” Aria-hidden ="true"(这是用于鼠标悬停时显示的SVG链接图标)

除了咏叹调/svg图标,当有人写道:

#标题标题

Github生成:

<h1><a id=“user-content-header-title” class=“anchor” href=“#header-title”>Header Title</a></h1>

因此,一个人不需要做任何事情来创建头链接,并且总是可以链接到它们:

链接到[标题标题](# Header - Title)

虽然姗姗来迟,但我认为这个添加可能对使用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).