Pandoc - 在生成之前插入页面目录
对于这个答案,我会假设你正在生成降价,尽管这个过程对于其他文件格式也是一样的。
关键的洞察力是Pandoc使用模板来确定最终放置。它具有默认模板,如果您修改它们,您可以更改部分的顺序。
-
查找默认的模板
> pandoc -D markdown $if(titleblock)$ $titleblock$ $endif$ $for(header-includes)$ $header-includes$ $endfor$ $for(include-before)$ $include-before$ $endfor$ $if(toc)$ $toc$ $endif$ $body$ $for(include-after)$ $include-after$ $endfor$
您不需要这个下一步,但如果你很好奇这些文件住,要求废话文件类型作品(虽然我”敢肯定有一个更好的方法):
> pandoc -D nonsense pandoc: Could not find data file /usr/local/.../templates/default.nonsense
-
复制和修改默认模板
> pandoc -D markdown > modified.markdown
使用你最喜欢的文本编辑器,你可以打开modified.markdown把
$body$
放在$toc$
之前。$body$ $if(toc)$ $toc$ $endif$
-
使用修改后的模板
> pandoc --template modified.markdown <... rest of your command ...>
我不确定这是OP所要求的:他们希望在TOC之前添加一些自定义页面,但不是整个主体,它应该仍然出现在后面。 – scoa 2016-10-04 19:55:16
是的,这个答案并没有真正考虑到在TOC之后身体仍然会**。我想在Markdown中创建一个应该在TOC之前出现的标题页。这可能吗? – 2016-12-08 12:21:38
我猜你想创建一个标题页或头信息的HTML文件。解决方案是在多个步骤中完成。
首先您将标题页一起编译为任何其他页面到一个html。 。
pandoc \ 01_HEADER.markdown -o了header.html
然后你包含了header.html身前:
pandoc -s -S -B --toc 。\ header.html。\ 02_Document.markdown -o complete_doc.html
完成。
的pandoc帮助各国它的可能性,使多部分文件可能,既-B和-H的工作,但我认为-B是在我的情况更正确。
-H FILENAME --include-in-header=FILENAME
-B FILENAME --include-before-body=FILENAME
-A FILENAME --include-after-body=FILENAME
在我来说,我有一个样式做并获得一个完美的文档:
pandoc -s -S -c .\res\github-pandoc.css .\01_HEADER.markdown -o header.html
pandoc -s -S --toc --toc-depth=2 -c .\res\github-pandoc.css -B .\header.html .\02_Document.markdown -o complete_document.html
是的,看看http://johnmacfarlane.net/pandoc/README.html#templates – mb21 2014-09-02 14:20:09