ste*_*938 57 markdown rdiscount
我正在尝试使用类似以下内容的section/subsection标题生成html:
- 我的顶级主题
1.1我的第一 个子主题
1.2另一个子主题
1.2.1一个子主题- 另一个顶级话题
是否有任何Markdown能够生成这些编号的章节标题?
提前致谢.
Ada*_*sen 48
是的,试试Pandoc.这对我有用:
pandoc --number-sections < test.md > out.html
Run Code Online (Sandbox Code Playgroud)
(来源)
Markdown生成您在原始帖子中提到的编号大纲,如下所示:
# My top-level topic
## My first subtopic
## Another subtopic
### A sub-subtopic
## Another top-level topic
Run Code Online (Sandbox Code Playgroud)
如果您想要更深入缩进子部分,您可以使用内联CSS实现此目的.例如,将其置于上述Markdown源的顶部会缩进标题:
<style type="text/css">
h2 { margin-left: 10px; }
h3 { margin-left: 20px; }
</style>
Run Code Online (Sandbox Code Playgroud)
但是你说你的标题下有段落的文字......我不知道如何缩进到与上面标题相同的级别.
更新2015-10-18:Markdeep已经编号(任何其他许多奇特的功能).检查一下!
ale*_*ung 14
如果您的降价工具支持CSS自定义主题,请将以下代码段添加到CSS中以启用标题号:
body {
counter-reset: h1
}
h1 {
counter-reset: h2
}
h2 {
counter-reset: h3
}
h3 {
counter-reset: h4
}
h1:before {
counter-increment: h1;
content: counter(h1) ". "
}
h2:before {
counter-increment: h2;
content: counter(h1) "." counter(h2) ". "
}
h3:before {
counter-increment: h3;
content: counter(h1) "." counter(h2) "." counter(h3) ". "
}
h4:before {
counter-increment: h4;
content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) ". "
}
Run Code Online (Sandbox Code Playgroud)
如果您想编辑 Markdown 文件本身,而不仅仅是生成的 HTML 文件,请尝试使用 python 3 enumerate-markdown
pip install enumerate-markdown
markdown-enum filename.md filename.md
Run Code Online (Sandbox Code Playgroud)
示例 - 输入
# header 1
text
## header 2
text
# header 3
text
Run Code Online (Sandbox Code Playgroud)
输出
# 1. header 1
text
## 1.1 header 2
text
# 2. header 3
text
Run Code Online (Sandbox Code Playgroud)
如果您稍后编辑该文件并再次运行该脚本,则会更新旧的枚举。