Skip to main content

No project description provided

Project description

CrissCross

CrissCross is a Markdown-centric templating engine.

Some of its features:

  • Replace Mustache-style placeholders
  • Include/import subfiles !INCLUDE "subfile.md"
  • Convert to other formats using pandoc or rmarkdown
Table of Contents - [CrissCross](#crisscross) - [Getting Started](#getting-started) - [Prerequisites](#prerequisites) - [Installation](#installation) - [Examples](#examples) - [Usage](#usage) - [Basic Usage](#basic-usage) - [Commands](#commands) - [Process](#process) - [Combine](#combine) - [File Inclusion](#file-inclusion) - [Roadmap](#roadmap) - [Built With](#built-with) - [Acknowledgments](#acknowledgments) - [Other related projects](#other-related-projects)

Getting Started

Prerequisites

Crisscross requires Python 3.

To convert files from one format to another, crisscross requires either pandoc, or rmarkdown.

Installation

pip3 install crisscross

Examples

Here are some sample use cases of CrissCross, ordered by increasing complexity.

  • English and Spanish: Generate PDFs of the same file with keywords in different languages.
  • PhD Applications: Generate personal statements customized for different schools.
  • Weekly Quiz: Generate quizzes and their solutions for 2 different sections using the same template.
    • The examples uses crisscross combine to take the "Cartesian product" of different sets of YAML metadata files, and crisscross process to generate PDF files from them.

Here's a sneak peek of the PhD applications example. CrissCross allows you to from a template that looks like this:

I am applying to **{{school_alt_name}}**’s PhD program because **{{school}}** is awesome. 

!INCLUDE "custom/{{school}}_last.md"

To PDFs like these:

Michigan UChicago

Usage

Basic Usage

Convert TEMPLATE.md into PDF, using key-value pairs specified in VARS.yaml:

crisscross process TEMPLATE.md -y VARS.yaml -o OUTDIR/TEMPLATE.pdf

Commands

There are two commands, process and combine.

Process

process is the command that processes the template files.

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

combine is a helper command takes the "Cartesian product" of lists of files.

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.

File Inclusion

Two inclusion tags are supported:

Adding asis after the inclusion tag will tell CrissCross to include the file as is, and not to further process it: !INCLUDE asis "foo.md"

Roadmap

  • Add the option to render inline placeholders as is
  • Add logic support

Built With

This project uses the following open source libraries.

Acknowledgments

This project is heavily inspired by:

Other related projects

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crisscross-0.1.4.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crisscross-0.1.4-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file crisscross-0.1.4.tar.gz.

File metadata

  • Download URL: crisscross-0.1.4.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.8.1

File hashes

Hashes for crisscross-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3ad3e27fecf7461877b18418a1c84218fe9ccecc10dbafa6c7fe6acb0c4f9e92
MD5 356252ad6d35b848905c18746b74cd4b
BLAKE2b-256 e5068758f336ddc28d82eaf06d113b53fb87fef20058ee7b87b7a7c0c2dd3c71

See more details on using hashes here.

File details

Details for the file crisscross-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: crisscross-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.8.1

File hashes

Hashes for crisscross-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 742c6ba1ca728ffdcd812e934669e1ed995f62c5866ddb81ec3a227191ed45fb
MD5 956d0764a12e6f67b9715ed0746b8d33
BLAKE2b-256 c78aa07b363154e15b8a69eea92af419e0f73f47bc1b924d22e72f939d28a85f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page