Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想.adoc使用 asciidoctor 从文件中生成 PDF
.adoc
asciidoctor-pdf Doku.adoc
如何将当前的 git sha1-hash 打印到 PDF 中?
使用DocumentAttributes
asciidoctor-pdf -acommitHash=$(git rev-parse HEAD) Doku.adoc
您现在可以commitHash通过编写以下方式在文档中使用文档属性:
commitHash
{commitHash}
用于ifdef测试是否设置了变量。
ifdef
ifdef::commitHash[] {commitHash} endif::[]
如果没有从 CLI 定义属性,您还可以将默认值定义为回退
:commit: Unknown Version: {commit}
命令行将-a覆盖文档内部声明。
-a