我正在尝试生成类似以下的节标题/子节标题的HTML:
- 我的一级主题
1.1 我的第一个子主题
1.2 另一个子主题
1.2.1 一个子子主题- 另一个一级主题
有哪些Markdown实现可以生成这种带编号的节标题?
是的,尝试一下Pandoc。这对我很有效:
pandoc --number-sections < test.md > out.html
(来源)
要生成原帖所提到的有序大纲,Markdown 代码如下:
# My top-level topic
## My first subtopic
## Another subtopic
### A sub-subtopic
## Another top-level topic
<style type="text/css">
h2 { margin-left: 10px; }
h3 { margin-left: 20px; }
</style>
但是假设您在标题下有一些段落文字...我不知道如何将其缩进到与上面的标题相同的级别。
更新于2015年10月18日:Markdeep拥有编号标题(和许多其他高级功能)。也请查看一下!
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) ". "
}
h1 { counter-increment: h1 }
,然后注释掉 h1:before
中的 counter-increment: h1
。我不明白为什么... - Alexpip 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
如果您稍后编辑文件并再次运行脚本,则会更新旧枚举。
markdown-enum
作为命令而不是包名enumerate-markdown
)。虽然如此,但正是我正在寻找的! - ijosephnumbersections: true
来为你的文件启用编号标题。Markdown旨在快速、轻便且易于使用,它完美地实现了这一目标。对于更复杂的格式,最好考虑除markdown之外的选项。这不是逃避责任。通常情况下,例如在Microsoft语言和工具中,我想做“xyz”,然后意识到在那个世界里,你会被设计成远离“xyz”,而是采用首选/支持的方式来实现你的目标。
以vscode为例,考虑工具栏/自定义。Vscode并不是以工具栏为中心的。这是有意设计的。设计意图是使用命令面板Ctrl+Shift+P。这样可以节省时间,不必不断地定制工具栏,并提供快速访问所有命令,而不仅仅是工具栏上的一部分命令。