未提供项目说明
crisscross的Python项目详细描述
纵横交错
crosscross是一个以降价为中心的模板引擎。在
它的一些特点:
入门
先决条件
安装
pip3 install crisscross
示例
下面是一些crosscross的示例用例,按复杂性的增加排序。在
- English and Spanish:用不同语言的关键字生成同一文件的pdf。在
- PhD Applications:生成为不同学校定制的个人声明。在
- Weekly Quiz:使用同一模板为两个不同的部分生成测验及其答案。
- 示例使用
crisscross combine
获取不同组YAML元数据文件的“笛卡尔积”,并使用crisscross process
从中生成PDF文件。在
- 示例使用
下面是一个PhD applications示例的预览。crosscross允许您从如下所示的模板开始:
^{pr2}$对于这样的PDF:
Michigan | UChicago |
---|---|
使用
命令
有两个命令,process
和combine
。在
过程
process
是处理模板文件的命令。在
示例
使用VARS.yaml
中指定的键值对将TEMPLATE.md
转换为PDF:
crisscross process TEMPLATE.md -y VARS.yaml -o OUTDIR/TEMPLATE.pdf
选项
Usage: crisscross process [OPTIONS] TEMPLATES...
Preprocess text files, and render with pandoc or rmarkdown.
Options:
-y, --yaml PATH The YAML file(s) to be used. If wildcard
characters are used, then the whole argument
must be quoted, e.g., -y '*.yaml'.
(Default: custom/*.yaml)
--no-yaml Use no YAML files. In this case, key-value
pairs must be supplied with -k --key-value.
(Default: disabled)
-o, --out PATH Schema for the path to an output file.
Variables are accepted.
(Default:
docs/{{id}}.pdf)
--open-ren / --no-open-ren Whether to open the rendered files
automatically.
(Default: enabled)
--open-text / --no-open-text Whether to open the generated text files
automatically.
(Default: disabled)
-a, --args TEXT A string of arguments to be passed on to
pandoc. Passing arguments to rmarkdown not
supported. If there are spaces, the string
should be quoted.
-r, --render [pandoc|rmarkdown]
Render using vanilla pandoc or rmarkdown, or
do not render at all.
(Default: pandoc)
--no-render Do not render the files with pandoc or
rmarkdown. Only do variable substitution or
file inclusion.
(Default: disabled)
--include-tag [include|import] Syntax for file inclusion. Either !INCLUDE
"filename" or @import "filename".
(Default:
include)
-V, --variable TEXT A key-value pair separated by ":". No spaces
allowed. Can be used in conjunction with or
in place of YAML files.
-f, --force Suppress warnings.
(Default: disabled)
-q, --quiet / -v, --verbose Suppress messages.
(Default: disabled)
-h, --help Show this message and exit.
联合收割机
combine
是一个helper命令,它接受文件列表的“笛卡尔积”。在
示例
crisscross combine a1,a2 b1,b2 -o out/
将在out/
下生成
out/
a1_b1
a1_b2
a2_b1
a2_b2
其中a1_b1
是a1
和{a1_b2
是{
请参见quiz示例,以了解combine.
的实际用例
选项
Usage: crisscross combine [OPTIONS][FILES]... Generate the 'Cartesian product' of multiple files. Options: -o, --out DIRECTORY Output directory. -s, --separator TEXT Character used to join the names of input files. -q, --quiet / -v, --verbose Suppress messages. (Default: disabled) -h, --help Show this message and exit.
文件包含
支持两个包含标记:
!INCLUDE "foo.md"
,样式为Markdown Preprocessor,并且@import "foo.md"
,样式为{a32}- 但是,与MPE不同,crosscross不支持
<!-- @import "foo.md" -->
。在
- 但是,与MPE不同,crosscross不支持
在inclusion标记后添加asis
将告诉crosscross按原样包含文件,而不是进一步处理它:!INCLUDE asis "foo.md"
键值对
键值对告诉crosscross如何替换占位符表达式。它们可以放在YAML文件中:
lang:Englishlevel:Level
或者,可以使用-V
选项提供它们:
crisscross process -V key1:value1 -V key2:value2 TEMPLATE -o OUTFILE
路线图
- []添加按原样呈现内联占位符的选项
- []添加对占位符表达式使用不同模式的选项
- []添加逻辑支持
用
此项目使用以下开放源代码库。在
- pallets/click:Python可组合命令行界面工具包
- hackebrot/poyo:Python的轻量级YAML解析器
- noahmorrison/chevron:胡子的Python实现
致谢
本项目的主要灵感来自:
- alpianon/include-pandoc:pandoc预处理的包装包括
- michaelstepner/pandoc-mustache:Pandoc过滤器,用于使用胡子语法替换变量
其他相关项目
- jreese/markdown-pp:用于生成目录和其他文档需求的降价文件的预处理器
- DCsunset/pandoc-include:允许文件包含的Pandoc筛选器
- owickstrom/pandoc-include-code:一个包含fr代码的Pandoc过滤器om源文件
- MrToph/pandoc-code-file-filter:pandoc的一个过滤器,用于包含文件中的代码部分
- 项目
标签: