未提供项目说明

crisscross的Python项目详细描述


纵横交错

crosscross是一个以降价为中心的模板引擎。在

它的一些特点:

  • 替换胡子样式占位符
  • 包含/导入子文件!INCLUDE "subfile.md"
  • 使用pandocrmarkdown转换为其他格式

入门

先决条件

安装

pip3 install crisscross

示例

下面是一些crosscross的示例用例,按复杂性的增加排序。在

  • English and Spanish:用不同语言的关键字生成同一文件的pdf。在
  • PhD Applications:生成为不同学校定制的个人声明。在
  • Weekly Quiz:使用同一模板为两个不同的部分生成测验及其答案。
    • 示例使用crisscross combine获取不同组YAML元数据文件的“笛卡尔积”,并使用crisscross process从中生成PDF文件。在

下面是一个PhD applications示例的预览。crosscross允许您从如下所示的模板开始:

^{pr2}$

对于这样的PDF:

MichiganUChicago

使用

命令

有两个命令,processcombine。在

过程

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_b1a1和{},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" -->。在

在inclusion标记后添加asis将告诉crosscross按原样包含文件,而不是进一步处理它:!INCLUDE asis "foo.md"

键值对

键值对告诉crosscross如何替换占位符表达式。它们可以放在YAML文件中:

lang:Englishlevel:Level

或者,可以使用-V选项提供它们:

crisscross process -V key1:value1 -V key2:value2 TEMPLATE -o OUTFILE

路线图

  • []添加按原样呈现内联占位符的选项
  • []添加对占位符表达式使用不同模式的选项
  • []添加逻辑支持

此项目使用以下开放源代码库。在

致谢

本项目的主要灵感来自:

其他相关项目

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java 401在API URL上带有声明性Http客户端,并带有@Secured(SecurityRule.IS_ANONYMOUS)注释   java如何在Android中创建计时器?   Java8WebStart安全弹出窗口   java会通过以下两种方式导致堆空间耗尽吗?   java项目调度GA:染色体的高效数据结构   java Apache POI:如何在Excel文件中插入列   java在JRE系统库中每个jar扮演什么角色   java如何在抽象类中执行@mock(不是注入mock)   java如何使用opensearch和Lucene发送搜索查询?   java在ApachePOI中处理空列   java广播接收器未接收到目标   java错误ELF类:ELF类64(可能原因:体系结构字宽不匹配)   java调用Web服务(SSL)时出错   用于iot集线器设备固件更新的java Rest API   通过xslt将xml转换为文本文件时引发java异常   Java linux打印问题   Java XML转换器重复行   java从另一个类的方法将数组导入mainActivity类   多线程选择与Java交互的线程   我想在java程序中打印以下格式的文件: