Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ickc/pancritic

Repository files navigation

title author fontfamily
Using CriticMarkup with pandoc
Kolen Cheung
lmodern,color,soul

fontfamily: lmodern,color,soul ...


# Usage #

`pandoc-criticmarkup.sh [options...] [file]`

Options:

- if no filename is given, it reads from the stdin
- accept: `-a`
- reject: `-r`
- permanent: `-p`
- show diff: `-d`
	- `-d html`: targeting html output using raw HTML
	- `-d tex`: targeting LaTeX output using raw LaTeX
	- `-d pdf`: same as above

If permanent is used, it will overwrite the original, if not, it will output to `stdout`. In most situation permanent should be used with `-a` or `-r` only, but it can be used with `-d` as well.

`-a`, `-r`, `-d` are supposed to use separately:

- If `-d` is used, the others are ignored,
- if `-r` is used, `-a` is ignored

It can be used with the pandoc commands, like these:

```bash
## Showing Difference and not overwriting
./pandoc-criticmarkup.sh -d html README.md | pandoc -s -o README.html
./pandoc-criticmarkup.sh -d pdf README.md | pandoc -s -o README.pdf
## accept or reject while overwriting the source
./pandoc-criticmarkup.sh -ap README-accept.md
./pandoc-criticmarkup.sh -rp README-reject.md

Caveats

The way this script works depends on the fact that pandoc allows raw HTML and raw LaTeX in the markdown source. The CriticMarkup is transformed into either a raw HTML or raw LaTeX representation (specified by the command line arguments).

Because of the asymmetry in the way pandoc handle raw HTML and raw LaTeX (namely, markdown inside raw HTML are parsed, but not in raw LaTeX), 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.

Another caveat is that nesting CriticMarkup might have unexpected behavior, especially in LaTeX output. For example, the test.md file do not have a valid LaTeX output because of nesting CriticMarkup.

Lastly, see the caveats section in the spec of CriticMarkup.

Todo

  • add a minimal CSS (especially for the HTML aside element)

Appendix

CSS

An optional CSS pandoc-criticmarkup.css make the deletions and additions more obvious in HTML output.

Mapping for Showing Differences

critic markup HTML LaTeX
{--[text]--} <del>[text]</del> \st{[text]}
{++[text]++} <ins>[text]</ins> \underline{[text]}
{~~[text1]~>[text2]~~} <del>[text1]</del><ins>[text2]</ins> \st{[text1]}\underline{[text2]}
{==[text]==} <mark>[text]</mark> \hl{[text]}
{>>[text]<<} <aside>[text]</aside> \marginpar{[text]}

Test Files From MMD

test.md is from MMD-Test-Suite/Critic.text at master · fletcher/MMD-Test-Suite