Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

using criticmarkup in the pandoc markdown source

License

NotificationsYou must be signed in to change notification settings

ickc/pancritic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build StatusGitHub ReleasesPyPI versionDevelopment StatusPython version

LicenseCoveralls

Using CriticMarkup with pandoc. It serves both as a wrapper and apre-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 athome. See help from

pancritic -h

A typical use of pancritic will be like

pancritic -s -o index.html index.md

See examples inHTML andPDF.

pancritic specific options

  • --engine
    The default engine ismarkdown. Valid options aremarkdown,markdown2,panflute,pypandoc. You need to install therespective package in order to use them.markdown andmarkdown2are pure Python, hence useful for other CPU architechture.panflute andpypandoc 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 togglingbetween diff, accept, reject.

    m/markup: treat the CriticMarkup as Markup. i.e. in HTML outputthere 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 completelychanged too. The former options of-a,-r,-d are replaced with-m a,-m r,-m d, and added a-m m.

Previous Users ofcriticParser_CLI.py

This is a heavy fork ofcriticParser_CLI.py, with these differences:

  1. CLI has changed, with a more pandoc-like interface.
  2. Python 3 (and 2) compatible.
  3. Bug fixes (formerly hightlight without comment are parsedincorrectly).
  4. 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 topancritic -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 outputextension is different. In pancritic, the to-format indicates theCriticMarkup parsing behavior (mainly tex vs. html). And the outputextension controls the final output’s format (e.g. markdown, html, etc.)

An interesting use of this is to use pancritic as a pandoc preprocessorinstead, 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 inLaTeX output. Seethe caveats section in the spec ofCriticMarkup.

  • 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 andinjecting the CSS/JS manually. Seepancritic/template.py for thetemplate used.

LaTeX Ouptut

Note that the LaTeX output requires the LaTeX packageschanges>=3.[1]

One can tell pandoc to use this package by either using a customtemplate or--include-in-header option. Or you can use the trick ofputting the following in your YAML front matter, like this file:

---fontfamily:lmodern,changes...

Markdown within the CriticMarkup will not be rendered in LaTeX output.If you want to change this behavior, you can take a look at:LaTeXArgumentParser.

CriticMarkupLaTeX
{--[text]--}\deleted{[text]}
{++[text]++}\added{[text]}
{~~[text1]~>[text2]~~}\replaced{[text2]}{[text1]}
{==[text]==}\highlight{[text]}
{>>[text]<<}\comment{[text]}

Translation from CriticMarkup to LaTeX.

Credits

  1. The version of the package in TeXLive 2018 is still v2.TeXLive 2019 should be availableon 2019-4-30, meanwhile you need to

    # sudo is needed in most cases, depending on where you put itsudo tlmgr update --selfsudo tlmgr update changes# check it is >=3tlmgr info changes

[8]ページ先頭

©2009-2025 Movatter.jp