潘多克包装风格
Panache的Python项目详细描述
华丽
build-statuscodefactorPypiKnown Vulnerabilities
概述
panache向Pandoc添加样式。
华而不实的想法与 panzer和 Pandocomatic。 它是另一个pandoc包装器,允许组装 pandoc命令行选项,-元数据和-筛选为样式。通过 这样,panache简化了pandoc调用并确保了 文件。
Panache与其他类似之处在于,可以在 单独的yaml文件和文档内。
Panache的不同之处在于它的样式可能包含变量 文档可以指定多个样式/上下文相关样式。
上下文可靠的样式
标记文档通常是不同目标的源。为了 例如,单个文档可以作为wiki的一部分转换为html 在编写文档时可以使用草稿html文件,并且 独立的html文件可以通过电子邮件发送。同时, 所有版本应使用私有样式呈现(根据 (例如)公司风格)。
为了解决这种情况,panache允许文档指定多个 样式,根据选定的媒体进行选择。
例如,假设文档具有以下元数据块:
---styles_:drafthtml:privatedrafthtmlfinalhtml:privatefinalhtmlwiki:wikihtml---
取决于命令行选项^{tt1}的值$ (darfthtml、finalhtml或wiki),Panache将选择 privatedrafthtml-、privatefinalhtml-或wikihtml-样式。 然后它将计算命令行(选项、过滤器和元数据) 对于选定的样式,最后调用pandoc。
级联样式定义
Panache允许在单独的yaml文件和 文件。名为wikihtml的样式的定义可能 如下所示:
---styledef_:wikihtml:commandline:template:/home/sebastian/templates/wiki-en.htmlmetadata:build-os:Linuxfilter:run:pandoc-citeproc---
第二个派生样式,用于更改模板(template), 可以通过添加:
---germanwikihtml:parent:wikihtmlcommandline:template:/home/sebastian/pandoc-templates/templates/wiki-de.html---
添加到前一个styledef_或将其添加到单独的 styledef_在另一个文件中。
样式变量
显然,上面的样式定义可能对用户有用 sebastian但对于其他用户可能会失败。这里就是 参数化样式定义起作用。
panache使用{{ mustache }}作为模板 样式文件的引擎。通过这个,panache允许使用“关键字” 在样式定义中,wich根据命令行选项替换 还有一些违约。使用这个,上面对 germanwikihtml-样式可以重写如下:
---germanwikihtml:parent:wikihtmlcommandline:template:{{home}}/pandoc-templates/wiki-de.html---
现在,如果--style-var=home:/home/sebastian被传递给panache, 然后template将被解析为 /home/sebastian/pandoc-templates/wiki-de.html(和 --template=/home/sebastian/pandoc-templates/wiki-de.html传递给 潘多克)。显然,使用--style-var=home:~会使调用 用户不可知(在bash中)。
使用正则{{ mustache }}-syntax可以表示 条件和重复。
安装
选项
使用Panache有两个选项:
- 运行python源代码
- 运行二进制版本
下面将介绍这两个选项。
python源代码
确保满足以下要求:
- Pandoc>;=2.1
- python>;=3.5
使用pip安装panache:
全球
pip install panache # /usr/lib/python3/dist-packages/panache/panache.py --version
或本地:
mkdir panache cd panache/ virtualenv -p /usr/bin/python3 venv source venv/bin/activate pip install panache # python3 ./venv/lib/python3.6/site-packages/panache/panache.py --version
详细信息
默认样式和元变量
默认情况下,如果 输入来自文件或标准输入:
Variable | Description |
---|---|
^{tt20}$ | directory of the panache script |
^{tt21}$ | panache version where ^{tt22}$, ^{tt23}$, ^{tt24}$ are major, minor and patch (see Semantic Versioning) |
^{tt25}$ | os type where ^{tt22}$ is one of ^{tt27}$, ^{tt28}$, ^{tt29}$, ^{tt30}$. |
^{tt31}$ | the date and time when panache was invoked (in the form ^{tt32}$) |
如果输入来自一个文件,则以下附加样式 默认情况下将添加元变量:
Variable | Description |
---|---|
^{tt33}$ | directory of the input file |
^{tt34}$ | basename of the input file |
^{tt35}$ | basename without extension of the input file |
^{tt36}$ | extension of the basename |
^{tt37}$ | vcs reference of the file |
^{tt38}$ | vcs date (last change) |
更多
待定。