在Markdown部分中添加锚点会导致呈现的Markdown中的部分标题中的HTML片段不完整

时间:2019-12-12 21:00:56

标签: html markdown

当我尝试使用此代码时

# Table of contents
1. [Introduction](#introduction)
2. [Some paragraph](#paragraph1)
    1. [Sub paragraph](#subparagraph1)
3. [Another paragraph](#paragraph2)

## This is the introduction <a name="introduction"></a>
Some introduction text, formatted in heading 2 style

## Some paragraph <a name="paragraph1"></a>
The first paragraph text

### Sub paragraph <a name="subparagraph1"></a>
This is a sub paragraph, formatted in heading 3 style

## Another paragraph <a name="paragraph2"></a>
The second paragraph text

我得到这个作为输出。

Introduction
Some paragraph
Sub paragraph
Another paragraph
" class="reference-link">This is the introduction
Some introduction text, formatted in heading 2 style

" class="reference-link">Some paragraph
The first paragraph text

" class="reference-link">Sub paragraph
This is a sub paragraph, formatted in heading 3 style

我的问题是我可以摆脱class="reference-link">位吗?

对于我的编辑器,我正在使用一个名为ipandao的在线编辑器 http://editor.md.ipandao.com/#introduction

我不知道它仅仅是编辑器还是一段代码。因为我对降价(.md)很陌生

2 个答案:

答案 0 :(得分:0)

Markdown编译器通常具有内置规则,可以自动将生成的ID或类名添加到标头中。您需要告诉编译器不要自动生成ID和类名,或者改用自动生成的ID和类名。

答案 1 :(得分:0)

<a>标签移动到它们应锚定的标题之前的行,如下所示:

# Table of contents
1. [Introduction](#introduction)
2. [Some paragraph](#paragraph1)
    1. [Sub paragraph](#subparagraph1)
3. [Another paragraph](#paragraph2)

<a name="introduction"></a>
## This is the introduction 
Some introduction text, formatted in heading 2 style

<a name="paragraph1"></a>
## Some paragraph
The first paragraph text

<a name="subparagraph1"></a>
### Sub paragraph
This is a sub paragraph, formatted in heading 3 style

<a name="paragraph2"></a>
## Another paragraph
The second paragraph text

我在ipandao上进行了测试,它摆脱了您看到的类引用链接片段,并且锚链接也很好用。