将 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 命令将其转换为 HTML
pandoc -i input.md -f markdown -t html -o input.html
这会创建一个我可以在 Firefox 中打开的有效 HTML 文件,内容 table 中的项目显示为链接 - 但是当我点击它们时,什么也没有发生了(我期待它跳转到相关部分)
当我使用 markdown
或 markdown_github
作为输入格式时(-i
in pandoc)
问题:
如何获取内容的 table 以显示 HTML 中的预期行为?
或者 'table of contents' 的概念是 HTML 的错误方法,我应该更改我的 markdown 代码吗?
抱歉,如果我以错误的方式解决这个问题,我没有使用 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)
我正在尝试使用 pandoc 将降价文档转换为 HTML。我无法获得 HTML 输出以正确创建内容的 table。
问题:
我在降价文档中添加了 table 内容,点击每个 header 会将 reader 转到相关部分。我使用下面的格式,点击 'Header Title' 会将 reader 发送到文档中的 'header' 部分:
[Header Title](#header)
- 我尝试使用 pandoc 命令将其转换为 HTML
pandoc -i input.md -f markdown -t html -o input.html
这会创建一个我可以在 Firefox 中打开的有效 HTML 文件,内容 table 中的项目显示为链接 - 但是当我点击它们时,什么也没有发生了(我期待它跳转到相关部分)
当我使用
markdown
或markdown_github
作为输入格式时(-i
in pandoc)
问题:
如何获取内容的 table 以显示 HTML 中的预期行为?
或者 'table of contents' 的概念是 HTML 的错误方法,我应该更改我的 markdown 代码吗?
抱歉,如果我以错误的方式解决这个问题,我没有使用 HTML / 网络文档的经验。
我发现了一些类似的
我在 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)