我正在尝试生成html,其节/分段标题类似于以下内容:
是否有任何标记的实现能够产生这类有编号的节标题?
提前谢谢。
发布于 2014-01-15 00:01:28
是的,试试潘多克。这对我来说很管用:
pandoc --number-sections < test.md > out.html(来源)
要生成您在原始文章中提到的编号大纲,请记下来如下所示:
# My top-level topic
## My first subtopic
## Another subtopic
### A sub-subtopic
## Another top-level topic如果您希望对子部分进行更深的缩进,则可以通过内联CSS实现这一点。例如,将其放置在上面的Markdown源的顶部会缩进标题:
<style type="text/css">
h2 { margin-left: 10px; }
h3 { margin-left: 20px; }
</style>但如果你的标题下有段落..。我不知道如何将其缩进与上面的标题相同的级别。
更新2015-10-18:马克迪普有编号标题(和许多其他花哨的功能)。你也来看看!
发布于 2017-04-26 04:31:01
如果您的标记工具支持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) ". "
}发布于 2018-06-25 23:33:45
如果您希望编辑标记文件本身,而不仅仅是生成的HTML文件,请尝试使用python 3的枚举标记。
pip install enumerate-markdown
markdown-enum filename.md 1 filename.md示例-输入
# header 1
text
## header 2
text
# header 3
text输出
# 1. header 1
text
## 1.1 header 2
text
# 2. header 3
text如果您稍后编辑该文件并再次运行该脚本,则它将更新旧枚举。
https://stackoverflow.com/questions/19999696
复制相似问题