CriticMarkdup parser with optional pandoc backend
Project description
- Date:
- March 11, 2018
Using CriticMarkup with pandoc. It serves both as a wrapper and a pre-processor.
Definition of CriticMarkup
Deletions: This is {–is –}a test.
Additions: This {++is ++}a test.
Substitutions: This {~~isn’t~>is~~} a test.
Highlighting: This is a {==test==}.
Comments: This is a test{>>What is a test for?<<}.
Installation
Install using
pip install pancritic
Usage: pancritic as a markdown wrapper (including but not limited to pandoc)
pancritic provides a pandoc-like cli. Pandoc users will feel right at home. See help from
pancritic -h
A typical use of pancritic will be like
pancritic -s -o index.html index.md
pancritic specific options
- --engine
The default engine is markdown. Valid options are markdown, markdown2, panflute, pypandoc. You need to install the respective package in order to use them. markdown and markdown2 are pure Python, hence useful for other CPU architechture. panflute and pypandoc both uses pandoc as backend.
- -m|--critic-mode
a/accept, r/reject: accept/reject changes.
d/diff: generates a diff. In HTML output, JS is used for toggling between diff, accept, reject. m/markup: treat the CriticMarkup as Markup. i.e. in HTML output there isn’t any toggles but the diff view only. In LaTeX output, diff and markup modes are identical except for an additional nav. -m m should be used with LaTeX output.
Previous Users
Previous Users of pandoc-criticmarkup
This is completely rewritten in Python. The cli has been completely changed too. The former options of -a, -r, -d are replaced with -m a, -m r, -m d, and added a -m m.
Previous Users of criticParser_CLI.py
This is a heavy fork of criticParser_CLI.py, with these differences:
CLI has changed, with a more pandoc-like interface.
Python 3 (and 2) compatible.
Bug fixes (formerly hightlight without comment are parsed incorrectly).
It has much more input/output format options as well as engines.
Examples,
criticParser_CLI.py input.md -m2 -o output.html --css css.html
# is equivalent to
pancritic -o output.html input.md --critic-template css.html --engine markdown2
Advanced Usage: pancritic as a pandoc preprocessor
A somewhat surprising behavior is when the to-format and output extension is different. In pancritic, the to-format indicates the CriticMarkup parsing behavior (mainly tex vs. html). And the output extension controls the final output’s format (e.g. markdown, html, etc.)
An interesting use of this is to use pancritic as a pandoc preprocessor instead, like this
pancritic input.md -t markdown -m m | pandoc -s -o output.html
This will be useful if more advanced pandoc args are needed.
Caveats
Nesting CriticMarkup might have unexpected behavior, especially in LaTeX output. See the caveats section in the spec of CriticMarkup.
mainly tested with HTML and LaTeX output. RST output almost works, but injecting CSS/JS into the output causes some problems. Currently, it can be get arround with --critic-template and injecting the CSS/JS manually. See pancritic/template.py for the template used.
LaTeX Ouptut
Note that the LaTeX output requires the LaTeX packages color and soul.
One can achieve this by either using a custom template or --include-in-header option. Or you can use the trick of putting the following in your YAML front matter, like this file:
---
fontfamily: lmodern,color,soul
...
Markdown within the CriticMarkup will not be rendered in LaTeX output. If you want to change this behavior, you can take a look at: LaTeX Argument Parser.
CriticMarkup |
LaTeX |
---|---|
{--[text]--} |
\st{[text]} |
{++[text]++} |
\underline{[text]} |
{~~[text1]~>[text2]~~} |
\st{[text1]}\underline{[text2]} |
{==[text]==} |
\hl{[text]} |
{>>[text]<<} |
\marginpar{[text]} |
Credits
Heavily modified from CriticMarkup Toolkit’s criticParser_CLI.py
tests.md is modified from MMD-Test-Suite/Critic.text at master · fletcher/MMD-Test-Suite
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
Built Distribution
File details
Details for the file pancritic-0.3.tar.gz
.
File metadata
- Download URL: pancritic-0.3.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 672c004f27c635f7dc3252ef302765d341d92e4f0ac975a78dbebd21c3cb5d5f |
|
MD5 | da644aa87d19d6a05d19d8620313886f |
|
BLAKE2b-256 | 8c4883bb6bd5b81f1bdd411ff8d3017734eb579dca14c1c4d4f04f55e8ad3901 |
File details
Details for the file pancritic-0.3-py3-none-any.whl
.
File metadata
- Download URL: pancritic-0.3-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf774a3d8bb20af956047331922f3b4c0d7a435a6cd9689ec71a51de2e8f0b20 |
|
MD5 | 04e7907801b1a555aa1fe6785be1dcf6 |
|
BLAKE2b-256 | 11e90ac608fd804d26b626a4b01765323a88a74fe46e1304a97b5fa62cff441a |