将 markdown table 的内容转换为 HTML

Convert markdown table of contents to HTML

我正在尝试使用 pandoc 将降价文档转换为 HTML。我无法获得 HTML 输出以正确创建内容的 table。

问题:

我在降价文档中添加了 table 内容,点击每个 header 会将 reader 转到相关部分。我使用下面的格式,点击 'Header Title' 会将 reader 发送到文档中的 'header' 部分:

[Header Title](#header)
pandoc -i input.md -f markdown -t html -o input.html

问题:

我发现了一些类似的 但它们似乎是特定于其他编程语言/工具的,因此非常感谢任何帮助我如何使用 markdown / pandoc 实现此目的的方法。

我在 Ubuntu 上使用 pandoc 1.19.2.4。

降价示例:


- [Chapter 1](#chapter-1)
    - [1. Reading a text file](#1-reading-a-text-file)


## Chapter 1

This post focuses on standard text processing tasks such as reading files and processing text.

### 1. Reading a text file

Reading a file. 

查看您的降价文件,您已使用 #1-reading-a-text-file 作为第一个副标题的 ID。

将其转换为 HTML 时,会为副标题生成以下行: <h3 id="reading-a-text-file">1. Reading a text file</h3>

问题是内容 table 中出现的“#1”不匹配,但标题中没有。 我的猜测是 pandoc 不允许 HTML id 以数字开头。

将内容的 table 更改为以下应该有效:

- [Chapter 1](#chapter-1)
    - [1. Reading a text file](#reading-a-text-file)