如何链接到Multimarkdown中的命名锚点?

本文翻译自:How to link to a named anchor in Multimarkdown?

I have come across a number of mentions of MultiMarkdown's support for internal links / named anchors but I am unable to find a single example of how to actually do it. 我遇到过一些关于MultiMarkdown对内部链接/命名锚点的支持的提及,但我无法找到如何实际执行此操作的单个示例。

So, what is the syntax for denoting the named anchor, and what is the syntax for linking to it the same as linking to any other URLs (only using #foo instead of http://.... )? 那么,表示命名锚的语法是什么,链接到它的语法是什么,与链接到任何其他URL相同(仅使用#foo而不是http://.... )?


#1楼

参考:https://stackoom.com/question/S5mx/如何链接到Multimarkdown中的命名锚点


#2楼

If you have headers in the markdown files, you can directly link them in the file. 如果您在markdown文件中有标题,则可以直接在文件中链接它们。

Markdown Header - Markdown标题 -

## The Header

this will generate an implicit id #the-header (replace internal spaces with hyphens and make lowercase). 这将生成一个隐式id #the-header (用连字符替换内部空格并使其成为小写)。

To navigate to this id, you can create the link like this: 要导航到此ID,您可以创建如下链接:

[Link to Header](#the-header)

This is equivalent to: 这相当于:

<a href="#the-header">Link to Header</a>

Please note the reference's name is a lower-case #header . 请注意,引用的名称是小写的#header


#3楼

The best way to create internal links (related with sections) is create list but instead of link, put #section or #section-title if the header includes spaces. 创建内部链接(与部分相关)的最佳方法是创建列表,但如果标题包含空格,则将#section或#section-title放入链接。

---- MARKDOWN ------------------------ ---- MARKDOWN ------------------------

Go to section
* [Hello](#hello)  
* [Hello World](#hello-world)
* [Another section](#new-section)    <-- it's called 'Another section' in this list but refers to 'New section'


## Hello
### Hello World
## New section

---- LIST PREVIEW ------------------------ ----列表预览------------------------

Go to section
Hello              <-- [Hello](#hello)                 -- go to `Hello` section
Hello World        <-- [Hello World](#hello world)     -- go to `Hello World` section
Another section    <-- [Another section](#new-section) -- go to `New section`

---- HTML ------------------------ ---- HTML ------------------------

<p>Go to section</p>
<ul>
<li><a href="#hello">Hello</a><br />
</li>
<li><a href="#hello-world">Hello World</a></li>
<li><a href="#new-section">Another section</a> &lt;– it’s called ‘Another section’ in this list but refers to ‘New section’</li>
</ul>
<h2 id="hello">Hello</h2>
<h3 id="hello-world">Hello World</h3>
<h2 id="new-section">New section</h2>

It doesn't matter whether it's h1, h2, h3, etc. header, you always refer to it using just one # . 无论是h1,h2,h3等标头,你总是只用一个#来引用它。
All references in section list should be converted to lowercase text as it is shown in the example above. 部分列表中的所有引用都应转换为小写文本,如上例所示。

Link to section should be lowercase. 链接到部分应该是小写的。 In other way it won't work. 换句话说它不起作用。
This technique works very well for all Markdown variants, also MultiMarkdown. 这种技术适用于所有Markdown变体,也适用于MultiMarkdown。

Currently I'm using the Pandoc to convert documents format. 目前我正在使用Pandoc转换文档格式。 It's much better than MultiMarkdown. 它比MultiMarkdown要好得多。
Test Pandoc here 在这里测试Pandoc


#4楼

I tested Github Flavored Markdown for a while and can summarize with four rules: 我测试了Github Flavored Markdown一段时间,可以总结四个规则:

  1. punctuation marks will be dropped 标点符号将被删除
  2. leading white spaces will be dropped 领先的白色空间将被丢弃
  3. upper case will be converted to lower 大写将转换为更低
  4. spaces between letters will be converted to - 字母之间的空格将转换为-

For example, if your section is named this: 例如,如果您的部分命名为:

## 1.1 Hello World

Create a link to it this way: 以这种方式创建一个链接:

[Link](#11-hello-world)

#5楼

Here is my solution (derived from SaraubhM 's answer) 这是我的解决方案(源自SaraubhM的回答)

**Jump To**: [Hotkeys & Markers](#hotkeys-markers) / [Radii](#radii) / [Route Wizard 2.0](#route-wizard-2-0)

Which gives you: 哪个给你:

Jump To : Hotkeys & Markers / Radii / Route Wizard 2.0 跳转到 :热键和标记/半径/路线向导2.0

Note the changes from 请注意来自的更改 and . . to - and also the loss of the & in the links. -以及链接中&的丢失。


#6楼

In mdcharm it is like this: 在mdcharm中它是这样的:

* [Descripción](#descripcion)
* [Funcionamiento](#funcionamiento)
* [Instalación](#instalacion)
* [Configuración](#configuracion)

### Descripción {#descripcion}
### Funcionamiento {#funcionamiento}
### Instalación {#instalacion}
### Configuración {#configuracion}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值