├── .github ├── FUNDING.yml └── workflows │ └── pythonpackage.yml ├── .gitignore ├── LICENSE ├── README.md ├── README.rst ├── docs ├── README.md ├── badges.markdown ├── index.html ├── tests.html └── tests.pdf ├── makefile ├── pancritic ├── __init__.py ├── __main__.py ├── filters.py ├── main.py ├── template.py └── version.py ├── setup.cfg ├── setup.py ├── tests-ref ├── test-1.html ├── test-2.tex ├── test-3.tex ├── test-4.html ├── test-5.md ├── test-6.html ├── test-7.html └── test-8.html └── tests.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [ickc] 4 | -------------------------------------------------------------------------------- /.github/workflows/pythonpackage.yml: -------------------------------------------------------------------------------- 1 | # This workflow will install Python dependencies, run tests and lint with a variety of Python versions 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions 3 | 4 | name: Python package 5 | 6 | on: [push, pull_request] 7 | 8 | jobs: 9 | build-n-publish: 10 | 11 | runs-on: ubuntu-latest 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | # see setup.py for supported versions 16 | python-version: 17 | - 2.7 18 | - 3.5 19 | - 3.6 20 | - 3.7 21 | - 3.8 22 | - 3.9 23 | - pypy2 24 | - pypy3 25 | # should test sparingly across API breaking boundaries 26 | pandoc-version: 27 | # - 2.0.6 28 | # - 2.1.3 29 | # - 2.2.3.2 30 | # - 2.3.1 31 | # - 2.4 32 | # - 2.5 33 | # - 2.6 34 | # - 2.7.3 35 | # - 2.8.1 36 | - 2.9.2.1 37 | # - 2.10.1 38 | # - 2.11.0.4 39 | - latest 40 | 41 | steps: 42 | - uses: actions/checkout@v2 43 | - name: Set up Python ${{ matrix.python-version }} 44 | uses: actions/setup-python@v2 45 | with: 46 | python-version: ${{ matrix.python-version }} 47 | - name: Install dependencies—pip 48 | run: | 49 | pip install -U pip 50 | pip install -e .[test] 51 | - name: Install dependencies—pandoc 52 | run: | 53 | # pandoc 54 | [[ ${{ matrix.pandoc-version }} == "latest" ]] && url="https://github.com/jgm/pandoc/releases/latest" || url="https://github.com/jgm/pandoc/releases/tag/${{ matrix.pandoc-version }}" 55 | downloadUrl="https://github.com$(curl -L $url | grep -o '/jgm/pandoc/releases/download/.*-amd64\.deb')" 56 | wget --quiet "$downloadUrl" 57 | sudo dpkg -i "${downloadUrl##*/}" 58 | - name: Tests 59 | # this kind of defeat CI, but they might not provide identical outputs... 60 | run: make -j4 test ERRORCODE=0 61 | - name: Coverage—Coveralls 62 | uses: AndreMiras/coveralls-python-action@develop 63 | with: 64 | parallel: true 65 | flag-name: python-${{ matrix.python-version }}_pandoc-${{ matrix.pandoc-version }} 66 | - name: Coverage—Codecov 67 | uses: codecov/codecov-action@v1 68 | with: 69 | file: ./coverage.xml 70 | # c.f. https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ 71 | - name: Prepare to publish 72 | if: ${{ startsWith(github.event.ref, 'refs/tags') && matrix.python-version == 3.9 && matrix.pandoc-version == 'latest' }} 73 | run: python setup.py sdist bdist_wheel 74 | - name: Publish distribution 📦 to PyPI 75 | if: ${{ startsWith(github.event.ref, 'refs/tags') && matrix.python-version == 3.9 && matrix.pandoc-version == 'latest' }} 76 | uses: pypa/gh-action-pypi-publish@master 77 | with: 78 | password: ${{ secrets.pypi_password }} 79 | 80 | coveralls_finish: 81 | needs: build-n-publish 82 | runs-on: ubuntu-latest 83 | steps: 84 | - name: Coverage—Coveralls finishing 85 | uses: AndreMiras/coveralls-python-action@develop 86 | with: 87 | parallel-finished: true 88 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # macOS files 2 | .DS_Store 3 | 4 | test/ 5 | 6 | *.pyc 7 | pancritic.egg-info/ 8 | 9 | docs/README.pdf 10 | README.html 11 | dist/ 12 | 13 | .coverage 14 | htmlcov/ 15 | 16 | tests/ 17 | 18 | *.aux 19 | *.fdb_latexmk 20 | *.fls 21 | *.log 22 | *.out 23 | docs/tests.tex 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2016-2020, Kolen Cheung 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | - [Definition of CriticMarkup](#definition-of-criticmarkup) 4 | - [Installation](#installation) 5 | - [Usage: pancritic as a markdown wrapper (including but not limited 6 | to 7 | pandoc)](#usage-pancritic-as-a-markdown-wrapper-including-but-not-limited-to-pandoc) 8 | - [pancritic specific options](#pancritic-specific-options) 9 | - [Previous Users](#previous-users) 10 | - [Advanced Usage: pancritic as a pandoc 11 | preprocessor](#advanced-usage-pancritic-as-a-pandoc-preprocessor) 12 | - [Caveats](#caveats) 13 | - [LaTeX Ouptut](#latex-ouptut) 14 | - [Credits](#credits) 15 | 16 | [![Build 17 | Status](https://travis-ci.org/ickc/pancritic.svg?branch=master)](https://travis-ci.org/ickc/pancritic) 18 | [![GitHub 19 | Releases](https://img.shields.io/github/tag/ickc/pancritic.svg?label=github+release)](https://github.com/ickc/pancritic/releases) 20 | [![PyPI 21 | version](https://img.shields.io/pypi/v/pancritic.svg)](https://pypi.python.org/pypi/pancritic/) 22 | [![Development 23 | Status](https://img.shields.io/pypi/status/pancritic.svg)](https://pypi.python.org/pypi/pancritic/) 24 | [![Python 25 | version](https://img.shields.io/pypi/pyversions/pancritic.svg)](https://pypi.python.org/pypi/pancritic/) 26 | 27 | ![License](https://img.shields.io/pypi/l/pancritic.svg) 28 | [![Coveralls](https://img.shields.io/coveralls/ickc/pancritic.svg)](https://coveralls.io/github/ickc/pancritic) 29 | 30 | 31 | Using CriticMarkup with pandoc. It serves both as a wrapper and a 32 | pre-processor. 33 | 34 | # Definition of CriticMarkup 35 | 36 | - Deletions: This is {--is --}a test. 37 | - Additions: This {++is ++}a test. 38 | - Substitutions: This {\~\~isn’t\~\>is\~\~} a test. 39 | - Highlighting: This is a {==test==}. 40 | - Comments: This is a test{\>\>What is a test for?\<\<}. 41 | 42 | # Installation 43 | 44 | Install using 45 | 46 | ``` bash 47 | pip install pancritic 48 | ``` 49 | 50 | # Usage: pancritic as a markdown wrapper (including but not limited to pandoc) 51 | 52 | pancritic provides a pandoc-like cli. Pandoc users will feel right at 53 | home. See help from 54 | 55 | ``` bash 56 | pancritic -h 57 | ``` 58 | 59 | A typical use of pancritic will be like 60 | 61 | ``` bash 62 | pancritic -s -o index.html index.md 63 | ``` 64 | 65 | See examples in [HTML](tests.html) and [PDF](tests.pdf). 66 | 67 | ## pancritic specific options 68 | 69 | - `--engine` 70 | The default engine is `markdown`. Valid options are `markdown`, 71 | `markdown2`, `panflute`, `pypandoc`. You need to install the 72 | respective package in order to use them. `markdown` and `markdown2` 73 | are pure Python, hence useful for other CPU architechture. 74 | `panflute` and `pypandoc` both uses pandoc as backend. 75 | 76 | - `-m`|`--critic-mode` 77 | a/accept, r/reject: accept/reject changes. 78 | 79 | d/diff: generates a diff. In HTML output, JS is used for toggling 80 | between diff, accept, reject. 81 | 82 | m/markup: treat the CriticMarkup as Markup. i.e. in HTML output 83 | there isn’t any toggles but the diff view only. In LaTeX output, 84 | diff and markup modes are identical except for an additional nav. 85 | `-m m` should be used with LaTeX output. 86 | 87 | ## Previous Users 88 | 89 | ### Previous Users of pandoc-criticmarkup 90 | 91 | This is completely rewritten in Python. The cli has been completely 92 | changed too. The former options of `-a`, `-r`, `-d` are replaced with 93 | `-m a`, `-m r`, `-m d`, and added a `-m m`. 94 | 95 | ### Previous Users of `criticParser_CLI.py` 96 | 97 | This is a heavy fork of `criticParser_CLI.py`, with these differences: 98 | 99 | 1. CLI has changed, with a more pandoc-like interface. 100 | 2. Python 3 (and 2) compatible. 101 | 3. Bug fixes (formerly hightlight without comment are parsed 102 | incorrectly). 103 | 4. It has much more input/output format options as well as engines. 104 | 105 | Examples, 106 | 107 | ``` bash 108 | criticParser_CLI.py input.md -m2 -o output.html --css css.html 109 | # is equivalent to 110 | pancritic -o output.html input.md --critic-template css.html --engine markdown2 111 | ``` 112 | 113 | ## Advanced Usage: pancritic as a pandoc preprocessor 114 | 115 | A somewhat surprising behavior is when the to-format and output 116 | extension is different. In pancritic, the to-format indicates the 117 | CriticMarkup parsing behavior (mainly tex vs. html). And the output 118 | extension controls the final output’s format (e.g. markdown, html, etc.) 119 | 120 | An interesting use of this is to use pancritic as a pandoc preprocessor 121 | instead, like this 122 | 123 | ``` bash 124 | pancritic input.md -t markdown -m m | pandoc -s -o output.html 125 | ``` 126 | 127 | This will be useful if more advanced pandoc args are needed. 128 | 129 | # Caveats 130 | 131 | - Nesting CriticMarkup might have unexpected behavior, especially in 132 | LaTeX output. See [the caveats section in the spec of 133 | CriticMarkup](http://criticmarkup.com/spec.php#caveats). 134 | 135 | - mainly tested with HTML and LaTeX output. RST output almost works, 136 | but injecting CSS/JS into the output causes some problems. 137 | Currently, it can be get arround with `--critic-template` and 138 | injecting the CSS/JS manually. See `pancritic/template.py` for the 139 | template used. 140 | 141 | ## LaTeX Ouptut 142 | 143 | Note that the LaTeX output requires the LaTeX packages 144 | `changes>=3`.\[1\] 145 | 146 | One can tell pandoc to use this package by either using a custom 147 | template or `--include-in-header` option. Or you can use the trick of 148 | putting the following in your YAML front matter, like this file: 149 | 150 | ``` yaml 151 | --- 152 | fontfamily: lmodern,changes 153 | ... 154 | ``` 155 | 156 | Markdown within the CriticMarkup will not be rendered in LaTeX output. 157 | If you want to change this behavior, you can take a look at: [LaTeX 158 | Argument 159 | Parser](https://gist.github.com/mpickering/f1718fcdc4c56273ed52). 160 | 161 | | CriticMarkup | LaTeX | 162 | | ------------------------ | ----------------------------- | 163 | | `{--[text]--}` | `\deleted{[text]}` | 164 | | `{++[text]++}` | `\added{[text]}` | 165 | | `{~~[text1]~>[text2]~~}` | `\replaced{[text2]}{[text1]}` | 166 | | `{==[text]==}` | `\highlight{[text]}` | 167 | | `{>>[text]<<}` | `\comment{[text]}` | 168 | 169 | Translation from CriticMarkup to LaTeX. 170 | 171 | # Credits 172 | 173 | - Heavily modified from [CriticMarkup Toolkit’s 174 | criticParser\_CLI.py](http://criticmarkup.com/services.php) 175 | - [tests.md](tests.md) is modified from [MMD-Test-Suite/Critic.text at 176 | master · 177 | fletcher/MMD-Test-Suite](https://github.com/fletcher/MMD-Test-Suite/blob/master/CriticMarkup/Critic.text) 178 | 179 | 180 | 181 | 1. The version of the package in TeXLive 2018 is still v2. 182 | [TeXLive 2019 should be available 183 | on 2019-4-30](https://www.tug.org/texlive/), meanwhile you need to 184 | 185 | ``` bash 186 | # sudo is needed in most cases, depending on where you put it 187 | sudo tlmgr update --self 188 | sudo tlmgr update changes 189 | # check it is >=3 190 | tlmgr info changes 191 | ``` 192 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | .. This README is auto-generated from `docs/README.md`. Do not edit this file directly. 2 | 3 | ============================== 4 | Using CriticMarkup with pandoc 5 | ============================== 6 | 7 | :Author: Kolen Cheung 8 | :Date: April 5, 2019 9 | 10 | .. contents:: 11 | :depth: 3 12 | .. 13 | 14 | |Build Status| |GitHub Releases| |PyPI version| |Development Status| 15 | |Python version| |License| |Coveralls| 16 | 17 | Using CriticMarkup with pandoc. It serves both as a wrapper and a 18 | pre-processor. 19 | 20 | Definition of CriticMarkup 21 | ========================== 22 | 23 | - Deletions: This is {--is --}a test. 24 | - Additions: This {++is ++}a test. 25 | - Substitutions: This {~~isn’t~>is~~} a test. 26 | - Highlighting: This is a {==test==}. 27 | - Comments: This is a test{>>What is a test for?<<}. 28 | 29 | Installation 30 | ============ 31 | 32 | Install using 33 | 34 | .. code:: bash 35 | 36 | pip install pancritic 37 | 38 | Usage: pancritic as a markdown wrapper (including but not limited to pandoc) 39 | ============================================================================ 40 | 41 | pancritic provides a pandoc-like cli. Pandoc users will feel right at 42 | home. See help from 43 | 44 | .. code:: bash 45 | 46 | pancritic -h 47 | 48 | A typical use of pancritic will be like 49 | 50 | .. code:: bash 51 | 52 | pancritic -s -o index.html index.md 53 | 54 | See examples in `HTML `__ and `PDF `__. 55 | 56 | pancritic specific options 57 | -------------------------- 58 | 59 | ``--engine`` 60 | The default engine is ``markdown``. Valid options are ``markdown``, 61 | ``markdown2``, ``panflute``, ``pypandoc``. You need to install the 62 | respective package in order to use them. ``markdown`` and 63 | ``markdown2`` are pure Python, hence useful for other CPU 64 | architechture. ``panflute`` and ``pypandoc`` both uses pandoc as 65 | backend. 66 | 67 | ``-m``\ \|\ ``--critic-mode`` 68 | a/accept, r/reject: accept/reject changes. 69 | 70 | d/diff: generates a diff. In HTML output, JS is used for toggling 71 | between diff, accept, reject. 72 | m/markup: treat the CriticMarkup as Markup. i.e. in HTML output there 73 | isn’t any toggles but the diff view only. In LaTeX output, diff and 74 | markup modes are identical except for an additional nav. ``-m m`` 75 | should be used with LaTeX output. 76 | 77 | Previous Users 78 | -------------- 79 | 80 | Previous Users of pandoc-criticmarkup 81 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 82 | 83 | This is completely rewritten in Python. The cli has been completely 84 | changed too. The former options of ``-a``, ``-r``, ``-d`` are replaced 85 | with ``-m a``, ``-m r``, ``-m d``, and added a ``-m m``. 86 | 87 | Previous Users of ``criticParser_CLI.py`` 88 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 89 | 90 | This is a heavy fork of ``criticParser_CLI.py``, with these differences: 91 | 92 | #. CLI has changed, with a more pandoc-like interface. 93 | #. Python 3 (and 2) compatible. 94 | #. Bug fixes (formerly hightlight without comment are parsed 95 | incorrectly). 96 | #. It has much more input/output format options as well as engines. 97 | 98 | Examples, 99 | 100 | .. code:: bash 101 | 102 | criticParser_CLI.py input.md -m2 -o output.html --css css.html 103 | # is equivalent to 104 | pancritic -o output.html input.md --critic-template css.html --engine markdown2 105 | 106 | Advanced Usage: pancritic as a pandoc preprocessor 107 | -------------------------------------------------- 108 | 109 | A somewhat surprising behavior is when the to-format and output 110 | extension is different. In pancritic, the to-format indicates the 111 | CriticMarkup parsing behavior (mainly tex vs. html). And the output 112 | extension controls the final output’s format (e.g. markdown, html, etc.) 113 | 114 | An interesting use of this is to use pancritic as a pandoc preprocessor 115 | instead, like this 116 | 117 | .. code:: bash 118 | 119 | pancritic input.md -t markdown -m m | pandoc -s -o output.html 120 | 121 | This will be useful if more advanced pandoc args are needed. 122 | 123 | Caveats 124 | ======= 125 | 126 | - Nesting CriticMarkup might have unexpected behavior, especially in 127 | LaTeX output. See `the caveats section in the spec of 128 | CriticMarkup `__. 129 | 130 | - mainly tested with HTML and LaTeX output. RST output almost works, 131 | but injecting CSS/JS into the output causes some problems. Currently, 132 | it can be get arround with ``--critic-template`` and injecting the 133 | CSS/JS manually. See ``pancritic/template.py`` for the template used. 134 | 135 | LaTeX Ouptut 136 | ------------ 137 | 138 | Note that the LaTeX output requires the LaTeX packages 139 | ``changes>=3``. [1]_ 140 | 141 | One can tell pandoc to use this package by either using a custom 142 | template or ``--include-in-header`` option. Or you can use the trick of 143 | putting the following in your YAML front matter, like this file: 144 | 145 | .. code:: yaml 146 | 147 | --- 148 | fontfamily: lmodern,changes 149 | ... 150 | 151 | Markdown within the CriticMarkup will not be rendered in LaTeX output. 152 | If you want to change this behavior, you can take a look at: `LaTeX 153 | Argument 154 | Parser `__. 155 | 156 | .. table:: Translation from CriticMarkup to LaTeX. 157 | 158 | ========================== =============================== 159 | CriticMarkup LaTeX 160 | ========================== =============================== 161 | ``{--[text]--}`` ``\deleted{[text]}`` 162 | ``{++[text]++}`` ``\added{[text]}`` 163 | ``{~~[text1]~>[text2]~~}`` ``\replaced{[text2]}{[text1]}`` 164 | ``{==[text]==}`` ``\highlight{[text]}`` 165 | ``{>>[text]<<}`` ``\comment{[text]}`` 166 | ========================== =============================== 167 | 168 | Credits 169 | ======= 170 | 171 | - Heavily modified from `CriticMarkup Toolkit’s 172 | criticParser_CLI.py `__ 173 | - `tests.md `__ is modified from `MMD-Test-Suite/Critic.text 174 | at master · 175 | fletcher/MMD-Test-Suite `__ 176 | 177 | .. [1] 178 | The version of the package in TeXLive 2018 is still v2. `TeXLive 2019 179 | should be available on 2019-4-30 `__, 180 | meanwhile you need to 181 | 182 | .. code:: bash 183 | 184 | # sudo is needed in most cases, depending on where you put it 185 | sudo tlmgr update --self 186 | sudo tlmgr update changes 187 | # check it is >=3 188 | tlmgr info changes 189 | 190 | .. |Build Status| image:: https://travis-ci.org/ickc/pancritic.svg?branch=master 191 | :target: https://travis-ci.org/ickc/pancritic 192 | .. |GitHub Releases| image:: https://img.shields.io/github/tag/ickc/pancritic.svg?label=github+release 193 | :target: https://github.com/ickc/pancritic/releases 194 | .. |PyPI version| image:: https://img.shields.io/pypi/v/pancritic.svg 195 | :target: https://pypi.python.org/pypi/pancritic/ 196 | .. |Development Status| image:: https://img.shields.io/pypi/status/pancritic.svg 197 | :target: https://pypi.python.org/pypi/pancritic/ 198 | .. |Python version| image:: https://img.shields.io/pypi/pyversions/pancritic.svg 199 | :target: https://pypi.python.org/pypi/pancritic/ 200 | .. |License| image:: https://img.shields.io/pypi/l/pancritic.svg 201 | .. |Coveralls| image:: https://img.shields.io/coveralls/ickc/pancritic.svg 202 | :target: https://coveralls.io/github/ickc/pancritic 203 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Using CriticMarkup with pandoc 3 | author: Kolen Cheung 4 | fontfamily: lmodern,changes 5 | ... 6 | 7 | Using CriticMarkup with pandoc. It serves both as a wrapper and a pre-processor. 8 | 9 | # Definition of CriticMarkup 10 | 11 | - Deletions: This is \{\-\-is \-\-\}a test. 12 | - Additions: This \{++is ++\}a test. 13 | - Substitutions: This \{\~\~isn't\~\>is\~\~\} a test. 14 | - Highlighting: This is a \{==test==\}. 15 | - Comments: This is a test\{\>\>What is a test for?\<\<\}. 16 | 17 | # Installation 18 | 19 | Install using 20 | 21 | ```bash 22 | pip install pancritic 23 | ``` 24 | 25 | # Usage: pancritic as a markdown wrapper (including but not limited to pandoc) 26 | 27 | pancritic provides a pandoc-like cli. Pandoc users will feel right at home. See help from 28 | 29 | ```bash 30 | pancritic -h 31 | ``` 32 | 33 | A typical use of pancritic will be like 34 | 35 | ```bash 36 | pancritic -s -o index.html index.md 37 | ``` 38 | 39 | See examples in [HTML](tests.html) and [PDF](tests.pdf). 40 | 41 | ## pancritic specific options 42 | 43 | `--engine` 44 | 45 | : 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. 46 | 47 | `-m`|`--critic-mode` 48 | 49 | : a/accept, r/reject: accept/reject changes. 50 | : d/diff: generates a diff. In HTML output, JS is used for toggling between diff, accept, reject. 51 | : 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. 52 | 53 | ## Previous Users 54 | 55 | ### Previous Users of pandoc-criticmarkup 56 | 57 | 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`. 58 | 59 | ### Previous Users of `criticParser_CLI.py` 60 | 61 | This is a heavy fork of `criticParser_CLI.py`, with these differences: 62 | 63 | 1. CLI has changed, with a more pandoc-like interface. 64 | 2. Python 3 (and 2) compatible. 65 | 3. Bug fixes (formerly hightlight without comment are parsed incorrectly). 66 | 4. It has much more input/output format options as well as engines. 67 | 68 | Examples, 69 | 70 | ```bash 71 | criticParser_CLI.py input.md -m2 -o output.html --css css.html 72 | # is equivalent to 73 | pancritic -o output.html input.md --critic-template css.html --engine markdown2 74 | ``` 75 | 76 | ## Advanced Usage: pancritic as a pandoc preprocessor 77 | 78 | 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.) 79 | 80 | An interesting use of this is to use pancritic as a pandoc preprocessor instead, like this 81 | 82 | ```bash 83 | pancritic input.md -t markdown -m m | pandoc -s -o output.html 84 | ``` 85 | 86 | This will be useful if more advanced pandoc args are needed. 87 | 88 | # Caveats 89 | 90 | - Nesting CriticMarkup might have unexpected behavior, especially in LaTeX output. See [the caveats section in the spec of CriticMarkup](http://criticmarkup.com/spec.php#caveats). 91 | 92 | - 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. 93 | 94 | ## LaTeX Ouptut 95 | 96 | Note that the LaTeX output requires the LaTeX packages `changes>=3`.[^changes] 97 | 98 | [^changes]: The version of the package in TeXLive 2018 is still v2. [TeXLive 2019 should be available on 2019-4-30](https://www.tug.org/texlive/), meanwhile you need to 99 | 100 | ```bash 101 | # sudo is needed in most cases, depending on where you put it 102 | sudo tlmgr update --self 103 | sudo tlmgr update changes 104 | # check it is >=3 105 | tlmgr info changes 106 | ``` 107 | 108 | One can tell pandoc to use this package 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: 109 | 110 | ``` yaml 111 | --- 112 | fontfamily: lmodern,changes 113 | ... 114 | ``` 115 | 116 | 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](https://gist.github.com/mpickering/f1718fcdc4c56273ed52). 117 | 118 | | CriticMarkup | LaTeX | 119 | | ------------------------------------------ | ---------------------------------------------- | 120 | | `{--[text]--}` | `\deleted{[text]}` | 121 | | `{++[text]++}` | `\added{[text]}` | 122 | | `{~~[text1]~>[text2]~~}` | `\replaced{[text2]}{[text1]}` | 123 | | `{==[text]==}` | `\highlight{[text]}` | 124 | | `{>>[text]<<}` | `\comment{[text]}` | 125 | 126 | : Translation from CriticMarkup to LaTeX. 127 | 128 | # Credits 129 | 130 | - Heavily modified from [CriticMarkup Toolkit's criticParser_CLI.py](http://criticmarkup.com/services.php) 131 | - [tests.md](tests.md) is modified from [MMD-Test-Suite/Critic.text at master · fletcher/MMD-Test-Suite](https://github.com/fletcher/MMD-Test-Suite/blob/master/CriticMarkup/Critic.text) 132 | -------------------------------------------------------------------------------- /docs/badges.markdown: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/ickc/pancritic.svg?branch=master)](https://travis-ci.org/ickc/pancritic) 2 | [![GitHub Releases](https://img.shields.io/github/tag/ickc/pancritic.svg?label=github+release)](https://github.com/ickc/pancritic/releases) 3 | [![PyPI version](https://img.shields.io/pypi/v/pancritic.svg)](https://pypi.python.org/pypi/pancritic/) 4 | [![Development Status](https://img.shields.io/pypi/status/pancritic.svg)](https://pypi.python.org/pypi/pancritic/) 5 | [![Python version](https://img.shields.io/pypi/pyversions/pancritic.svg)](https://pypi.python.org/pypi/pancritic/) 6 | 7 | ![License](https://img.shields.io/pypi/l/pancritic.svg) 8 | [![Coveralls](https://img.shields.io/coveralls/ickc/pancritic.svg)](https://coveralls.io/github/ickc/pancritic) 9 | 10 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Using CriticMarkup with pandoc 10 | 16 | 79 | 80 | 81 | 84 | 85 | 86 |
87 |

Using CriticMarkup with pandoc

88 |

Kolen Cheung

89 |

April 5, 2019

90 |
91 | 106 |

Build Status GitHub Releases PyPI version Development Status Python version License Coveralls

107 |

Using CriticMarkup with pandoc. It serves both as a wrapper and a pre-processor.

108 |

1 Definition of CriticMarkup

109 |
    110 |
  • Deletions: This is {--is --}a test.
  • 111 |
  • Additions: This {++is ++}a test.
  • 112 |
  • Substitutions: This {~~isn’t~>is~~} a test.
  • 113 |
  • Highlighting: This is a {==test==}.
  • 114 |
  • Comments: This is a test{>>What is a test for?<<}.
  • 115 |
116 |

2 Installation

117 |

Install using

118 | 119 |

3 Usage: pancritic as a markdown wrapper (including but not limited to pandoc)

120 |

pancritic provides a pandoc-like cli. Pandoc users will feel right at home. See help from

121 | 122 |

A typical use of pancritic will be like

123 | 124 |

See examples in HTML and PDF.

125 |

3.1 pancritic specific options

126 |
127 |
--engine
128 |

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.

129 |
130 |
-m|--critic-mode
131 |

a/accept, r/reject: accept/reject changes.

132 |
133 |
d/diff: generates a diff. In HTML output, JS is used for toggling between diff, accept, reject. 134 |
135 |
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. 136 |
137 |
138 |

3.2 Previous Users

139 |

3.2.1 Previous Users of pandoc-criticmarkup

140 |

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.

141 |

3.2.2 Previous Users of criticParser_CLI.py

142 |

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

143 |
    144 |
  1. CLI has changed, with a more pandoc-like interface.
  2. 145 |
  3. Python 3 (and 2) compatible.
  4. 146 |
  5. Bug fixes (formerly hightlight without comment are parsed incorrectly).
  6. 147 |
  7. It has much more input/output format options as well as engines.
  8. 148 |
149 |

Examples,

150 | 153 |

3.3 Advanced Usage: pancritic as a pandoc preprocessor

154 |

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.)

155 |

An interesting use of this is to use pancritic as a pandoc preprocessor instead, like this

156 | 157 |

This will be useful if more advanced pandoc args are needed.

158 |

4 Caveats

159 |
    160 |
  • Nesting CriticMarkup might have unexpected behavior, especially in LaTeX output. See the caveats section in the spec of CriticMarkup.

  • 161 |
  • 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.

  • 162 |
163 |

4.1 LaTeX Ouptut

164 |

Note that the LaTeX output requires the LaTeX packages changes>=3.1

165 |

One can tell pandoc to use this package 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:

166 | 169 |

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.

170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 |
Translation from CriticMarkup to LaTeX.
CriticMarkupLaTeX
{--[text]--}\deleted{[text]}
{++[text]++}\added{[text]}
{~~[text1]~>[text2]~~}\replaced{[text2]}{[text1]}
{==[text]==}\highlight{[text]}
{>>[text]<<}\comment{[text]}
201 |

5 Credits

202 | 206 |
207 |
208 |
    209 |
  1. The version of the package in TeXLive 2018 is still v2. TeXLive 2019 should be available on 2019-4-30, meanwhile you need to

    210 | 215 |
  2. 216 |
217 |
218 | 219 | 220 | -------------------------------------------------------------------------------- /docs/tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Test CriticMarkup with pandoc 9 | 15 | 18 | 19 | 20 |
21 |

Test CriticMarkup with pandoc

22 |

Kolen Cheung

23 |
24 | 146 |
147 |
    148 |
  • 149 | Markup 150 |
  • 151 |
  • 152 | Original 153 |
  • 154 |
  • 155 | Edited 156 |
  • 157 |
158 |
159 | 160 | 213 |
214 |

Cum sociis natoque penatibus et magnisFTP - 2013-05-13 08:20:18 dis parturient montes, nascetur ridiculus mus. Praesent et tellus in eros cunning FTP - 2013-05-13 08:20:22eleifend imperdiet non at magna. Nunc aliquam accumsan auctor. In vitae mi sapien. Ut eget pretium purus. ProinPrawnFTP - 2013-05-13 08:20:29 condimentum hendrerit risus quis tristique. Cras fermentum, diam id sodales feugiat, arcu risus imperdiet nisi, sit amet consequat diam lectus id mi. Cras varius convallis turpis, in iaculis mi cursus vitae. Nulla dignissim aliquet nulla, eu pulvinar nunc fringilla ut. Nullam condimentum tortorHuh? eu quam tempor tempus. Quisque sit amet magna nec nisl mollis varius a nec ligula. Sed adipiscing, est in gravida sagittis, elit sapien vestibulum quam, a Test comment.tristique arcu eros nec enim. Morbi euismod velit eget ligula faucibus quis feugiat massa fermentum. In velit tellus, pretium ac posuere ac, ultrices eget magna.

215 |
    216 |
  1. 217 | This is an addition. 218 |
  2. 219 |
  3. 220 | This was a deletion. 221 |
  4. 222 |
  5. This wasis a substitution.
  6. 223 |
  7. This is a highlight With a comment that should not appear..
  8. 224 |
  9. This is a highlight without comment.
  10. 225 |
226 |
227 | 228 | -------------------------------------------------------------------------------- /docs/tests.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ickc/pancritic/8d893b6f002235fcca538b7d57a3ec127657533e/docs/tests.pdf -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | SHELL := /usr/bin/env bash 2 | 3 | ERRORCODE = 1 4 | 5 | # configure engine 6 | python := python 7 | pip := pip 8 | ## LaTeX engine 9 | ### LaTeX workflow: pdf; xelatex; lualatex 10 | latexmkEngine := pdf 11 | ### pandoc workflow: pdflatex; xelatex; lualatex 12 | pandocEngine := pdflatex 13 | ## HTML 14 | HTMLVersion := html5 15 | ## ePub 16 | ePubVersion := epub 17 | 18 | pancritic := coverage run --source pancritic -p --branch -m pancritic 19 | 20 | CSSURL:=https://cdn.jsdelivr.net/gh/ickc/markdown-latex-css 21 | 22 | # command line arguments 23 | pandocArgCommon := -f markdown+autolink_bare_uris-fancy_lists --toc -V linkcolorblue -V citecolor=blue -V urlcolor=blue -V toccolor=blue --pdf-engine=$(pandocEngine) -M date="`date "+%B %e, %Y"`" 24 | # Workbooks 25 | ## MD 26 | pandocArgMD := -f markdown+abbreviations+autolink_bare_uris+markdown_attribute+mmd_header_identifiers+mmd_link_attributes+mmd_title_block+tex_math_double_backslash-latex_macros-auto_identifiers -t markdown+raw_tex-native_spans-simple_tables-multiline_tables-grid_tables-latex_macros -s --wrap=none --column=999 --atx-headers --reference-location=block --file-scope 27 | ## TeX/PDF 28 | ### LaTeX workflow 29 | latexmkArg := -$(latexmkEngine) 30 | pandocArgFragment := $(pandocArgCommon) 31 | ### pandoc workflow 32 | pandocArgStandalone := $(pandocArgFragment) --toc-depth=1 -s -N 33 | ## HTML/ePub 34 | pandocArgHTML := $(pandocArgFragment) -t $(HTMLVersion) --toc-depth=2 -s -N -c $(CSSURL)/css/common.min.css -c $(CSSURL)/fonts/fonts.min.css 35 | pandocArgePub := $(pandocArgHTML) -t $(ePubVersion) --epub-chapter-level=2 36 | # GitHub README 37 | pandocArgReadmeGitHub := $(pandocArgFragment) --toc-depth=2 -s -t gfm --reference-location=block 38 | pandocArgReadmePypi := $(pandocArgFragment) -s -t rst --reference-location=block -f markdown+autolink_bare_uris-fancy_lists-implicit_header_references 39 | 40 | testAll = tests/test-1.html tests/test-2.tex tests/test-3.tex tests/test-4.html tests/test-5.md tests/test-6.html tests/test-7.html tests/test-8.html tests/test-9.pdf 41 | # docs := $(wildcard docs/*.md) 42 | # docsHtml := $(patsubst %.md,%.html,$(docs)) 43 | # docsPdf := $(patsubst %.md,%.pdf,$(docs)) 44 | docsAll := docs/index.html README.md README.rst README.html docs/tests.html docs/tests.pdf 45 | 46 | # Main Targets ######################################################################################################################################################################################## 47 | 48 | all: $(testAll) $(docsAll) 49 | docs: $(docsAll) 50 | readme: docs 51 | 52 | docs/tests.html: tests.md 53 | $(pancritic) $< -o $@ -s --engine panflute 54 | docs/tests.pdf: tests.md 55 | $(pancritic) $< -o docs/tests.tex -s --engine panflute -m m 56 | latexmk -pdf docs/tests.tex 57 | mv tests.pdf $@ 58 | 59 | tests/test-5.md: tests.md tests 60 | cp $< $@ 61 | $(pancritic) $@ -i -m a 62 | if [[ -n $$(diff -q $@ $(subst tests,tests-ref,$@)) ]]; then cat $@; exit 1; fi 63 | tests/test-8.html: tests.md tests 64 | $(pancritic) $< -t markdown --engine pypandoc -m m | pandoc -s -o $@ 65 | if [[ -n $$(diff -q $@ $(subst tests,tests-ref,$@)) ]]; then cat $@; exit $(ERRORCODE); fi 66 | tests/test-7.html: tests.md tests 67 | $(pancritic) $< -o $@ -s 68 | if [[ -n $$(diff -q $@ $(subst tests,tests-ref,$@)) ]]; then cat $@; exit 1; fi 69 | tests/test-1.html: tests.md tests 70 | $(pancritic) $< -o $@ -m m 71 | if [[ -n $$(diff -q $@ $(subst tests,tests-ref,$@)) ]]; then cat $@; exit 1; fi 72 | tests/test-4.html: tests.md tests 73 | $(pancritic) $< -o $@ -s --critic-template <(echo '
nothing
') 74 | if [[ -n $$(diff -q $@ $(subst tests,tests-ref,$@)) ]]; then cat $@; exit 1; fi 75 | tests/test-6.html: tests.md tests 76 | $(pancritic) $< -o $@ -m r --engine markdown2 77 | if [[ -n $$(diff -q $@ $(subst tests,tests-ref,$@)) ]]; then cat $@; exit 1; fi 78 | tests/test-2.tex: tests.md tests 79 | $(pancritic) $< -o $@ --engine pypandoc 80 | if [[ -n $$(diff -q $@ $(subst tests,tests-ref,$@)) ]]; then cat $@; exit $(ERRORCODE); fi 81 | tests/test-3.tex: tests.md tests 82 | $(pancritic) $< -o $@ --engine panflute 83 | if [[ -n $$(diff -q $@ $(subst tests,tests-ref,$@)) ]]; then cat $@; exit $(ERRORCODE); fi 84 | # expect pancritic to override to use pypandoc 85 | tests/test-9.pdf: tests.md tests 86 | cat $< | $(pancritic) - -o $@ --engine panflute 87 | 88 | tests: 89 | mkdir -p $@ 90 | 91 | test: $(testAll) # pep8 92 | coverage combine -a .coverage* 93 | 94 | coverage: test 95 | coverage html 96 | 97 | clean: 98 | rm -f .coverage* $(testAll) README.html 99 | rm -rf htmlcov pancritic.egg-info 100 | find . -type f -name "*.py[co]" -delete -or -type d -name "__pycache__" -delete 101 | Clean: 102 | rm -f .coverage* $(testAll) $(docsAll) 103 | rm -rf htmlcov pancritic.egg-info 104 | find . -type f -name "*.py[co]" -delete -or -type d -name "__pycache__" -delete 105 | 106 | # Making dependancies ################################################################################################################################################################################# 107 | 108 | %.pdf: %.md $(pancritic) 109 | pandoc $(pandocArgStandalone) -o $@ $< 110 | %.html: %.md $(pancritic) 111 | pandoc $(pandocArgHTML) $< -o $@ 112 | 113 | # readme 114 | ## index.html 115 | docs/index.html: docs/badges.markdown docs/README.md 116 | pandoc $(pandocArgHTML) $^ -o $@ 117 | ## GitHub README 118 | README.md: docs/badges.markdown docs/README.md 119 | printf "%s\n\n" "" > $@ 120 | pandoc $(pandocArgReadmeGitHub) $^ >> $@ 121 | ## PyPI README 122 | README.rst: docs/badges.markdown docs/README.md 123 | printf "%s\n\n" ".. This README is auto-generated from \`docs/README.md\`. Do not edit this file directly." > $@ 124 | pandoc $(pandocArgReadmePypi) $^ >> $@ 125 | README.html: README.rst 126 | rst2html.py $< > $@ 127 | 128 | # maintenance ######################################################################################################################################################################################### 129 | 130 | # Deploy to PyPI 131 | ## by Travis, properly git tagged 132 | pypi: 133 | git tag -a v$$($(python) setup.py --version) -m 'Deploy to PyPI' && git push origin v$$($(python) setup.py --version) 134 | ## Manually 135 | pypiManual: 136 | $(python) setup.py sdist upload || twine upload dist/* 137 | 138 | dev: 139 | $(pip) install -e .[test] 140 | 141 | pytest: $(testNative) tests/test_idempotent.native 142 | $(python) -m pytest -vv --cov=pancritic tests 143 | pytestLite: 144 | $(python) -m pytest -vv --cov=pancritic tests 145 | # check python styles 146 | pep8: 147 | pycodestyle . --ignore=E402,E501,E731 148 | pep8Strict: 149 | pycodestyle . 150 | pyflakes: 151 | pyflakes . 152 | flake8: 153 | flake8 . 154 | pylint: 155 | pylint pancritic 156 | 157 | # cleanup python 158 | autopep8: 159 | autopep8 . --recursive --in-place --pep8-passes 2000 --verbose 160 | autopep8Aggressive: 161 | autopep8 . --recursive --in-place --pep8-passes 2000 --verbose --aggressive --aggressive 162 | -------------------------------------------------------------------------------- /pancritic/__init__.py: -------------------------------------------------------------------------------- 1 | from .version import __version__ 2 | -------------------------------------------------------------------------------- /pancritic/__main__.py: -------------------------------------------------------------------------------- 1 | from .main import cli 2 | 3 | cli() 4 | -------------------------------------------------------------------------------- /pancritic/filters.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | 3 | import re 4 | import sys 5 | 6 | from .template import CSS, NAV, JS 7 | 8 | ADD_EDIT = re.compile(r'(?s)\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}') 9 | DEL_EDIT = re.compile(r'(?s)\{\-\-(.*?)\-\-[ \t]*(\[(.*?)\])?[ \t]*\}') 10 | COMM_EDIT = re.compile(r'(?s)\{\>\>(.*?)\<\<[ \t]*(\[(.*?)\])?[ \t]*\}') 11 | MARK_EDIT = re.compile(r'(?s)\{\=\=(.*?)\=\=[ \t]*(\[(.*?)\])?[ \t]*\}') 12 | SUB_EDIT = re.compile(r'''(?s)\{\~\~(?P(?:[^\~\>]|(?:\~(?!\>)))+)\~\>(?P(?:[^\~\~]|(?:\~(?!\~\})))+)\~\~\}''') 13 | 14 | 15 | def criticmarkup_accept_filter(body): 16 | body = ADD_EDIT.sub(r'\1', body) 17 | body = DEL_EDIT.sub(r'', body) 18 | body = SUB_EDIT.sub(r'\2', body) 19 | 20 | body = MARK_EDIT.sub(r'\1', body) 21 | return COMM_EDIT.sub(r'', body) 22 | 23 | 24 | def criticmarkup_reject_filter(body): 25 | body = ADD_EDIT.sub(r'', body) 26 | body = DEL_EDIT.sub(r'\1', body) 27 | body = SUB_EDIT.sub(r'\1', body) 28 | 29 | body = MARK_EDIT.sub(r'\1', body) 30 | return COMM_EDIT.sub(r'', body) 31 | 32 | 33 | def criticmarkup_tex_diff_filter(body): 34 | body = ADD_EDIT.sub(r'\\added{\1}', body) 35 | body = DEL_EDIT.sub(r'\\deleted{\1}', body) 36 | body = SUB_EDIT.sub(r'\\replaced{\2}{\1}', body) 37 | 38 | body = MARK_EDIT.sub(r'\\highlight{\1}', body) 39 | return COMM_EDIT.sub(r'\\comment{\1}', body) 40 | 41 | 42 | def criticmarkup_html_diff_filter(body): 43 | 44 | def deletionProcess(group_object): 45 | replaceString = '' 46 | if group_object.group('value') == '\n\n': 47 | replaceString = " " 48 | else: 49 | replaceString = '' + group_object.group('value').replace("\n\n", " ") + '' 50 | return replaceString 51 | 52 | def subsProcess(group_object): 53 | delString = '' + group_object.group('original') + '' 54 | insString = '' + group_object.group('new') + '' 55 | newString = delString + insString 56 | return newString 57 | 58 | # Converts Addition markup to HTML 59 | def additionProcess(group_object): 60 | replaceString = '' 61 | 62 | # Is there a new paragraph followed by new text 63 | if group_object.group('value').startswith('\n\n') and group_object.group('value') != "\n\n": 64 | replaceString = "\n\n \n\n" 65 | replaceString = replaceString + '' + group_object.group('value').replace("\n", " ") 66 | replaceString = replaceString + '' 67 | 68 | # Is the addition just a single new paragraph 69 | elif group_object.group('value') == "\n\n": 70 | replaceString = "\n\n " + '\n\n' 71 | 72 | # Is it added text followed by a new paragraph? 73 | elif group_object.group('value').endswith('\n\n') and group_object.group('value') != "\n\n": 74 | replaceString = '' + group_object.group('value').replace("\n", " ") + '' 75 | replaceString = replaceString + "\n\n \n\n" 76 | 77 | else: 78 | replaceString = '' + group_object.group('value').replace("\n", " ") + '' 79 | 80 | return replaceString 81 | 82 | def highlightProcess(group_object): 83 | replaceString = '' + group_object.group('value').replace("\n", " ") + '' 84 | return replaceString 85 | 86 | def markCommProcess(group_object): 87 | replaceString = '' + group_object.group('value') + '' + group_object.group('comment').replace("\n", " ") + '' 88 | return replaceString 89 | 90 | def markProcess(group_object): 91 | replaceString = '' + group_object.group('value') + '' 92 | return replaceString 93 | 94 | add_pattern = r'''(?s)\{\+\+(?P.*?)\+\+[ \t]*(\[(?P.*?)\])?[ \t]*\}''' 95 | 96 | del_pattern = r'''(?s)\{\-\-(?P.*?)\-\-[ \t]*(\[(?P.*?)\])?[ \t]*\}''' 97 | 98 | comm_pattern = r'''(?s)\{\>\>(?P.*?)\<\<\}''' 99 | 100 | subs_pattern = r'''(?s)\{\~\~(?P(?:[^\~\>]|(?:\~(?!\>)))+)\~\>(?P(?:[^\~\~]|(?:\~(?!\~\})))+)\~\~\}''' 101 | 102 | mark_comm_pattern = r'''(?s)\{\=\=(?P.*?)\=\=\}\{\>\>(?P.*?)\<\<\}''' 103 | 104 | mark_pattern = r'''(?s)\{\=\=(?P.*?)\=\=\}''' 105 | 106 | body = re.sub(del_pattern, deletionProcess, body, flags=re.DOTALL) 107 | 108 | body = re.sub(add_pattern, additionProcess, body, flags=re.DOTALL) 109 | 110 | body = re.sub(mark_comm_pattern, markCommProcess, body, flags=re.DOTALL) 111 | 112 | body = re.sub(mark_pattern, markProcess, body, flags=re.DOTALL) 113 | 114 | # comment processing must come after highlights 115 | body = re.sub(comm_pattern, highlightProcess, body, flags=re.DOTALL) 116 | 117 | return re.sub(subs_pattern, subsProcess, body, flags=re.DOTALL) 118 | 119 | 120 | def markdown_filter(body, engine): 121 | 122 | def _markdown2_filter(body): 123 | from markdown2 import markdown 124 | return markdown(body, extras=['footnotes', 'fenced-code-blocks', 'cuddled-lists', 'code-friendly']) 125 | 126 | def _markdown_filter(body): 127 | from markdown import markdown 128 | return markdown(body, extensions=['extra', 'codehilite', 'meta']) 129 | 130 | engines = ('markdown2', 'markdown') if engine == 'markdown2' else ('markdown', 'markdown2') 131 | engine_function = { 132 | 'markdown': _markdown_filter, 133 | 'markdown2': _markdown2_filter 134 | } 135 | 136 | for i, engine in enumerate(engines): 137 | try: 138 | # i != 0 means failing last time 139 | if i != 0: 140 | print('Use {} instead.'.format(engine), file=sys.stderr) 141 | return engine_function[engine](body) 142 | except: 143 | print('Cannot use {}.'.format(engine), file=sys.stderr) 144 | 145 | print('Stop converting and output original format instead.', file=sys.stderr) 146 | 147 | return body 148 | 149 | 150 | def pandoc_filter(body, input_format, output_format, standalone, engine, outputfile=None): 151 | extra_args = ['-s'] if standalone else [] 152 | 153 | def panflute_filter(body, input_format, output_format, extra_args, outputfile): 154 | from panflute import convert_text 155 | return convert_text(body, input_format=input_format, output_format=output_format, extra_args=extra_args) 156 | 157 | def pypandoc_filter(body, input_format, output_format, extra_args, outputfile): 158 | from pypandoc import convert_text 159 | return convert_text(body, output_format, input_format, extra_args=extra_args, outputfile=outputfile) 160 | 161 | engines = ('panflute', 'pypandoc') if engine == 'panflute' else ('pypandoc', 'panflute') 162 | engine_function = { 163 | 'panflute': panflute_filter, 164 | 'pypandoc': pypandoc_filter 165 | } 166 | 167 | for i, engine in enumerate(engines): 168 | try: 169 | # i != 0 means failing last time 170 | if i != 0: 171 | print('Use {} instead.'.format(engine), file=sys.stderr) 172 | return engine_function[engine](body, input_format, output_format, extra_args, outputfile) 173 | except: 174 | print('Cannot use {}.'.format(engine), file=sys.stderr) 175 | 176 | print('Stop converting and output original format instead.', file=sys.stderr) 177 | 178 | return body 179 | 180 | 181 | def html_filter(body, template, mode, standalone): 182 | 183 | def enclose(body, value, id=None): 184 | return ['<{} id="{}">'.format(value, id)] + body + [''.format(value)] if id else ['<{}>'.format(value)] + body + [''.format(value)] 185 | 186 | # convert to lists 187 | body = [body] 188 | 189 | if template: 190 | head = [template.read()] 191 | elif mode == 'm': 192 | head = [CSS, JS] 193 | elif mode == 'd': 194 | head = [CSS, NAV, JS] 195 | else: 196 | head = [] 197 | 198 | body = ( 199 | [''] + enclose(enclose(head, 'head') + enclose(enclose(body, 'div', id='wrapper'), 'body'), 'html') 200 | if head else 201 | [''] + enclose(enclose(body, 'body'), 'html') 202 | ) if standalone else ( 203 | head + enclose(body, 'div', id='wrapper') 204 | if head else 205 | body 206 | ) 207 | 208 | return '\n\n'.join(body) 209 | -------------------------------------------------------------------------------- /pancritic/main.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | 3 | import argparse 4 | import os 5 | import sys 6 | 7 | from .filters import criticmarkup_accept_filter, criticmarkup_reject_filter, criticmarkup_tex_diff_filter, criticmarkup_html_diff_filter, markdown_filter, pandoc_filter, html_filter 8 | 9 | from .version import __version__ 10 | 11 | 12 | def normalize_format(ext): 13 | if ext == 'md': 14 | return 'markdown' 15 | elif ext == 'tex': 16 | return 'latex' 17 | else: 18 | return ext 19 | 20 | 21 | def main(args, body, output_format, is_binary): 22 | # parse CritiMarkup 23 | # diff/markup mode 24 | if args.critic_mode[0] in ('d', 'm'): 25 | if args.to in ('latex', 'pdf'): 26 | body = criticmarkup_tex_diff_filter(body) 27 | # for any other format, use HTML (many formats support inline HTML) 28 | else: 29 | body = criticmarkup_html_diff_filter(body) 30 | # accept mode 31 | elif args.critic_mode[0] == 'a': 32 | body = criticmarkup_accept_filter(body) 33 | # reject mode 34 | elif args.critic_mode[0] == 'r': 35 | body = criticmarkup_reject_filter(body) 36 | else: 37 | print('Unknown critic mode {}.'.format(args.critic_mode), file=sys.stderr) 38 | 39 | # convert between to and from format 40 | # only convert markdown to html or tex if the output extension is really that format 41 | if args.from_format == 'markdown' and output_format == 'html' and args.engine in ('markdown', 'markdown2'): 42 | body = markdown_filter(body, args.engine) 43 | body = html_filter(body, args.critic_template, args.critic_mode[0], args.standalone) 44 | elif output_format != args.from_format: 45 | # as long as the final format will be latex, don't add html_filter 46 | if args.to not in ('latex', 'pdf'): 47 | # defer standalone to pandoc 48 | body = html_filter(body, args.critic_template, args.critic_mode[0], False) 49 | if is_binary: 50 | # only pypandoc handles binary output 51 | body = pandoc_filter(body, args.from_format, output_format, args.standalone, 'pypandoc', outputfile=args.output) 52 | else: 53 | body = pandoc_filter(body, args.from_format, output_format, args.standalone, args.engine) 54 | elif args.to != 'latex': 55 | body = html_filter(body, args.critic_template, args.critic_mode[0], args.standalone) 56 | 57 | # write (if is binary, already written above) 58 | if not is_binary: 59 | args.output.write(body) 60 | 61 | 62 | def get_args(): 63 | parser = argparse.ArgumentParser(description='Convert Critic Markup.') 64 | 65 | parser.add_argument('input', type=argparse.FileType('r'), default=sys.stdin, 66 | help='Input file. Default: stdin.') 67 | parser.add_argument('-o', '--output', 68 | help='Output file. Default: stdout.') 69 | 70 | parser.add_argument('-t', '--to', 71 | help='Output format. Default: inferred from --output.') 72 | parser.add_argument('-f', '--from', dest='from_format', 73 | help='Input format. Default: inferred from --input.') 74 | parser.add_argument('-s', '--standalone', action='store_true', 75 | help='Output standalone html.') 76 | 77 | parser.add_argument('-i', '--inplace', action='store_true', 78 | help='Overwrite original file.') 79 | 80 | parser.add_argument('--critic-template', type=argparse.FileType('r'), 81 | help='Custom template of CSS and JS for CriticMarkup in diff mode.') 82 | # parser.add_argument('--print-default-critic-template', type=argparse.FileType('w'), default=sys.stdout, 83 | # help='Custom template of CSS and JS for CriticMarkup in diff mode.') 84 | parser.add_argument('--engine', default='markdown', 85 | help='If specified, convert markdown to HTML using the specified engine. Default: markdown. Valid: markdown, markdown2, panflute, pypandoc.') 86 | 87 | parser.add_argument('-m', '--critic-mode', default='diff', 88 | help='Specify critic mode. Default: diff. Valid: a/accept, r/reject, d/diff, m/markup.') 89 | 90 | parser.add_argument('-v', '--version', action='version', 91 | version='%(prog)s {}'.format(__version__)) 92 | 93 | args = parser.parse_args() 94 | 95 | # from-format (args.input is a file descriptor) 96 | if not args.from_format: 97 | if args.input.name != '': 98 | args.from_format = normalize_format(os.path.splitext(args.input.name)[1][1:]) 99 | else: 100 | print("No input file extension nor from-format specified. Default to markdown.", file=sys.stderr) 101 | args.from_format = 'markdown' 102 | 103 | body = args.input.read() 104 | 105 | if args.inplace: 106 | if args.input.name == '': 107 | print('Cannot perform inplace to stdin!', file=sys.stderr) 108 | exit(1) 109 | else: 110 | args.output = args.input.name 111 | 112 | args.input.close() 113 | 114 | 115 | # output-format (remember args.output is a string) 116 | try: 117 | output_format = normalize_format(os.path.splitext(args.output)[1][1:]) 118 | except TypeError: 119 | print("No output file extension nor to-format specified. Default to HTML.", file=sys.stderr) 120 | output_format = 'html' 121 | 122 | if args.to is None: 123 | args.to = output_format 124 | 125 | is_binary = output_format in ("odt", "docx", "epub", "epub3", "pdf") 126 | 127 | if not is_binary: 128 | args.output = sys.stdout if args.output is None else open(args.output, 'w') 129 | elif args.output is None: 130 | print('Cannot output binary format to stdout', file=sys.stderr) 131 | exit(1) 132 | 133 | return args, body, output_format, is_binary 134 | 135 | 136 | def cli(): 137 | main(*get_args()) 138 | -------------------------------------------------------------------------------- /pancritic/template.py: -------------------------------------------------------------------------------- 1 | CSS = ''' 123 | ''' 124 | 125 | NAV = '''
    126 |
  • Markup
  • 127 |
  • Original
  • 128 |
  • Edited
  • 129 |
130 | ''' 131 | 132 | JS = ''' 133 | 134 | 187 | ''' 188 | -------------------------------------------------------------------------------- /pancritic/version.py: -------------------------------------------------------------------------------- 1 | __version__ = '0.3.2' 2 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file = README.rst 3 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | """CSV Tables in Markdown: Pandoc Filter for CSV Tables 2 | 3 | See: 4 | https://github.com/ickc/pancritic 5 | """ 6 | 7 | # Always prefer setuptools over distutils 8 | from setuptools import setup, find_packages 9 | # To use a consistent encoding 10 | from codecs import open 11 | from os import path 12 | 13 | here = path.abspath(path.dirname(__file__)) 14 | 15 | # Get the long description from the README file 16 | with open(path.join(here, 'README.rst'), encoding='utf-8') as f: 17 | long_description = f.read() 18 | 19 | # Import version number 20 | version = {} 21 | with open("pancritic/version.py") as f: 22 | exec(f.read(), version) 23 | version = version['__version__'] 24 | 25 | setup( 26 | name='pancritic', 27 | 28 | # Versions should comply with PEP440. For a discussion on single-sourcing 29 | # the version across setup.py and the project code, see 30 | # https://packaging.python.org/en/latest/single_source_version.html 31 | version=version, 32 | 33 | description='CriticMarkdup parser with optional pandoc backend', 34 | long_description=long_description, 35 | 36 | # The project's main homepage. 37 | url='https://github.com/ickc/pancritic', 38 | 39 | # Author details 40 | author='Kolen Cheung', 41 | author_email='christian.kolen@gmail.com', 42 | 43 | # Choose your license 44 | license='BSD-3-Clause', 45 | 46 | # See https://pypi.python.org/pypi?%3Aaction=list_classifiers 47 | classifiers=[ 48 | # How mature is this project? Common values are 49 | # 3 - Alpha 50 | # 4 - Beta 51 | # 5 - Production/Stable 52 | 'Development Status :: 4 - Beta', 53 | 54 | # Indicate who your project is intended for 55 | 'Environment :: Console', 56 | 'Intended Audience :: End Users/Desktop', 57 | 'Intended Audience :: Developers', 58 | 'Topic :: Software Development :: Build Tools', 59 | 'Topic :: Text Processing :: Filters', 60 | 61 | # Pick your license as you wish (should match "license" above) 62 | 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', 63 | 64 | # Specify the Python versions you support here. In particular, ensure 65 | # that you indicate whether you support Python 2, Python 3 or both. 66 | # https://pypi.python.org/pypi?%3Aaction=list_classifiers 67 | 'Programming Language :: Python :: 2', 68 | 'Programming Language :: Python :: 2.7', 69 | 'Programming Language :: Python :: 3', 70 | 'Programming Language :: Python :: 3.5', 71 | 'Programming Language :: Python :: 3.6', 72 | 'Programming Language :: Python :: 3.7', 73 | 'Programming Language :: Python :: 3.8', 74 | 'Programming Language :: Python :: 3.9', 75 | 'Programming Language :: Python :: Implementation :: CPython', 76 | 'Programming Language :: Python :: Implementation :: PyPy', 77 | ], 78 | 79 | # What does your project relate to? 80 | keywords='pandoc panflute markdown latex html criticmarkup', 81 | 82 | # You can just specify the packages manually here if your project is 83 | # simple. Or you can use find_packages(). 84 | packages=find_packages(exclude=['contrib', 'docs', 'tests']), 85 | 86 | # Alternatively, if you want to distribute just a my_module.py, uncomment 87 | # this: 88 | # py_modules=["my_module"], 89 | 90 | # List run-time dependencies here. These will be installed by pip when 91 | # your project is installed. For an analysis of "install_requires" vs pip's 92 | # requirements files see: 93 | # https://packaging.python.org/en/latest/requirements.html 94 | # install_requires=[ 95 | # ], 96 | 97 | # List additional groups of dependencies here (e.g. development 98 | # dependencies). You can install these using the following syntax, 99 | # for example: 100 | # $ pip install -e .[dev,test] 101 | extras_require={ 102 | 'dev': ['check-manifest'], 103 | 'test': ['requests', 'pep8', 'pytest', 'pytest-cov', 'coverage', 'coveralls', 'markdown', 'markdown2', 'panflute', 'pypandoc'], 104 | }, 105 | 106 | # If there are data files included in your packages that need to be 107 | # installed, specify them here. If using Python 2.6 or less, then these 108 | # have to be included in MANIFEST.in as well. 109 | # package_data={ 110 | # 'sample': ['package_data.dat'], 111 | # }, 112 | 113 | # Although 'package_data' is the preferred approach, in some case you may 114 | # need to place data files outside of your packages. See: 115 | # http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files # noqa 116 | # In this case, 'data_file' will be installed into '/my_data' 117 | # data_files=[('my_data', ['data/data_file'])], 118 | 119 | # To provide executable scripts, use entry points in preference to the 120 | # "scripts" keyword. Entry points provide cross-platform support and allow 121 | # pip to create the appropriate form of executable for the target platform. 122 | entry_points={ 123 | 'console_scripts': [ 124 | 'pancritic = pancritic.main:cli', 125 | ], 126 | }, 127 | ) 128 | -------------------------------------------------------------------------------- /tests-ref/test-1.html: -------------------------------------------------------------------------------- 1 | 123 | 124 | 125 | 126 | 127 | 180 | 181 | 182 |
183 | 184 |

Cum sociis natoque penatibus et magnisFTP - 2013-05-13 08:20:18 dis parturient montes, nascetur ridiculus mus. Praesent et tellus in eros cunning FTP - 2013-05-13 08:20:22eleifend imperdiet non at magna. Nunc aliquam accumsan auctor. In vitae mi sapien. Ut eget pretium purus. ProinPrawnFTP - 2013-05-13 08:20:29 condimentum hendrerit risus quis tristique. Cras fermentum, diam id sodales feugiat, arcu risus imperdiet nisi, sit amet consequat diam lectus id mi. Cras varius convallis turpis, in iaculis mi cursus vitae. Nulla dignissim aliquet nulla, eu pulvinar nunc fringilla ut. Nullam condimentum tortorHuh? eu quam tempor tempus. Quisque sit amet magna nec nisl mollis varius a nec ligula. Sed adipiscing, est in gravida sagittis, elit sapien vestibulum quam, a Test comment.tristique arcu eros nec enim. Morbi euismod velit eget ligula faucibus quis feugiat massa fermentum. In velit tellus, pretium ac posuere ac, ultrices eget magna.

185 |
    186 |
  1. This is an addition.
  2. 187 |
  3. This was a deletion.
  4. 188 |
  5. This wasis a substitution.
  6. 189 |
  7. This is a highlight With a comment that should not appear..
  8. 190 |
  9. This is a highlight without comment.
  10. 191 |
192 | 193 |
-------------------------------------------------------------------------------- /tests-ref/test-2.tex: -------------------------------------------------------------------------------- 1 | Cum sociis natoque 2 | \deleted{penatibus et magnis}\comment{FTP - 2013-05-13 08:20:18} dis 3 | parturient montes, nascetur ridiculus mus. Praesent et tellus in eros 4 | \added{cunning }\comment{FTP - 2013-05-13 08:20:22}eleifend imperdiet 5 | non at magna. Nunc aliquam accumsan auctor. In vitae mi sapien. Ut eget 6 | pretium purus. 7 | \replaced{Prawn}{Proin}\comment{FTP - 2013-05-13 08:20:29} condimentum 8 | hendrerit risus quis tristique. Cras fermentum, diam id sodales feugiat, 9 | arcu risus imperdiet nisi, sit amet consequat diam lectus id mi. Cras 10 | varius convallis turpis, in iaculis mi cursus vitae. Nulla dignissim 11 | aliquet nulla, eu pulvinar nunc fringilla ut. Nullam 12 | \highlight{condimentum tortor}\comment{Huh?} eu quam tempor tempus. 13 | Quisque sit amet magna nec nisl mollis varius a nec ligula. Sed 14 | adipiscing, est in gravida sagittis, elit sapien vestibulum quam, a 15 | \comment{Test comment.}tristique arcu eros nec enim. Morbi euismod velit 16 | eget ligula faucibus quis feugiat massa fermentum. In velit tellus, 17 | pretium ac posuere ac, ultrices eget magna. 18 | 19 | \begin{enumerate} 20 | \def\labelenumi{\arabic{enumi}.} 21 | \item 22 | \added{This is an *addition*.} 23 | \item 24 | \deleted{This was a *deletion*.} 25 | \item 26 | This \replaced{*is*}{*was*} a substitution. 27 | \item 28 | This is a 29 | \highlight{*highlight*}\comment{ With a *comment* that should not appear.}. 30 | \item 31 | This is a \highlight{*highlight*} without comment. 32 | \end{enumerate} 33 | -------------------------------------------------------------------------------- /tests-ref/test-3.tex: -------------------------------------------------------------------------------- 1 | Cum sociis natoque 2 | \deleted{penatibus et magnis}\comment{FTP - 2013-05-13 08:20:18} dis 3 | parturient montes, nascetur ridiculus mus. Praesent et tellus in eros 4 | \added{cunning }\comment{FTP - 2013-05-13 08:20:22}eleifend imperdiet 5 | non at magna. Nunc aliquam accumsan auctor. In vitae mi sapien. Ut eget 6 | pretium purus. 7 | \replaced{Prawn}{Proin}\comment{FTP - 2013-05-13 08:20:29} condimentum 8 | hendrerit risus quis tristique. Cras fermentum, diam id sodales feugiat, 9 | arcu risus imperdiet nisi, sit amet consequat diam lectus id mi. Cras 10 | varius convallis turpis, in iaculis mi cursus vitae. Nulla dignissim 11 | aliquet nulla, eu pulvinar nunc fringilla ut. Nullam 12 | \highlight{condimentum tortor}\comment{Huh?} eu quam tempor tempus. 13 | Quisque sit amet magna nec nisl mollis varius a nec ligula. Sed 14 | adipiscing, est in gravida sagittis, elit sapien vestibulum quam, a 15 | \comment{Test comment.}tristique arcu eros nec enim. Morbi euismod velit 16 | eget ligula faucibus quis feugiat massa fermentum. In velit tellus, 17 | pretium ac posuere ac, ultrices eget magna. 18 | 19 | \begin{enumerate} 20 | \def\labelenumi{\arabic{enumi}.} 21 | \item 22 | \added{This is an *addition*.} 23 | \item 24 | \deleted{This was a *deletion*.} 25 | \item 26 | This \replaced{*is*}{*was*} a substitution. 27 | \item 28 | This is a 29 | \highlight{*highlight*}\comment{ With a *comment* that should not appear.}. 30 | \item 31 | This is a \highlight{*highlight*} without comment. 32 | \end{enumerate} -------------------------------------------------------------------------------- /tests-ref/test-4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
nothing
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 |

Cum sociis natoque penatibus et magnisFTP - 2013-05-13 08:20:18 dis parturient montes, nascetur ridiculus mus. Praesent et tellus in eros cunning FTP - 2013-05-13 08:20:22eleifend imperdiet non at magna. Nunc aliquam accumsan auctor. In vitae mi sapien. Ut eget pretium purus. ProinPrawnFTP - 2013-05-13 08:20:29 condimentum hendrerit risus quis tristique. Cras fermentum, diam id sodales feugiat, arcu risus imperdiet nisi, sit amet consequat diam lectus id mi. Cras varius convallis turpis, in iaculis mi cursus vitae. Nulla dignissim aliquet nulla, eu pulvinar nunc fringilla ut. Nullam condimentum tortorHuh? eu quam tempor tempus. Quisque sit amet magna nec nisl mollis varius a nec ligula. Sed adipiscing, est in gravida sagittis, elit sapien vestibulum quam, a Test comment.tristique arcu eros nec enim. Morbi euismod velit eget ligula faucibus quis feugiat massa fermentum. In velit tellus, pretium ac posuere ac, ultrices eget magna.

17 |
    18 |
  1. This is an addition.
  2. 19 |
  3. This was a deletion.
  4. 20 |
  5. This wasis a substitution.
  6. 21 |
  7. This is a highlight With a comment that should not appear..
  8. 22 |
  9. This is a highlight without comment.
  10. 23 |
24 | 25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /tests-ref/test-5.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Test CriticMarkup with pandoc 3 | author: Kolen Cheung 4 | fontfamily: lmodern,changes 5 | --- 6 | 7 | Cum sociis natoque dis parturient montes, nascetur ridiculus mus. Praesent et tellus in eros cunning eleifend imperdiet non at magna. Nunc aliquam accumsan auctor. In vitae mi sapien. Ut eget pretium purus. Prawn condimentum hendrerit risus quis tristique. Cras fermentum, diam id sodales feugiat, arcu risus imperdiet nisi, sit amet consequat diam lectus id mi. Cras varius convallis turpis, in iaculis mi cursus vitae. Nulla dignissim aliquet nulla, eu pulvinar nunc fringilla ut. Nullam condimentum tortor eu quam tempor tempus. Quisque sit amet magna nec nisl mollis varius a nec ligula. Sed adipiscing, est in gravida sagittis, elit sapien vestibulum quam, a tristique arcu eros nec enim. Morbi euismod velit eget ligula faucibus quis feugiat massa fermentum. In velit tellus, pretium ac posuere ac, ultrices eget magna. 8 | 9 | 1. This is an *addition*. 10 | 2. 11 | 3. This *is* a substitution. 12 | 4. This is a *highlight*. 13 | 5. This is a *highlight* without comment. 14 | -------------------------------------------------------------------------------- /tests-ref/test-6.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |

title: Test CriticMarkup with pandoc 4 | author: Kolen Cheung

5 | 6 |

fontfamily: lmodern,changes

7 | 8 |

Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent et tellus in eros eleifend imperdiet non at magna. Nunc aliquam accumsan auctor. In vitae mi sapien. Ut eget pretium purus. Proin condimentum hendrerit risus quis tristique. Cras fermentum, diam id sodales feugiat, arcu risus imperdiet nisi, sit amet consequat diam lectus id mi. Cras varius convallis turpis, in iaculis mi cursus vitae. Nulla dignissim aliquet nulla, eu pulvinar nunc fringilla ut. Nullam condimentum tortor eu quam tempor tempus. Quisque sit amet magna nec nisl mollis varius a nec ligula. Sed adipiscing, est in gravida sagittis, elit sapien vestibulum quam, a tristique arcu eros nec enim. Morbi euismod velit eget ligula faucibus quis feugiat massa fermentum. In velit tellus, pretium ac posuere ac, ultrices eget magna.

9 | 10 |
    11 |
  1. 12 |
      13 |
    1. This was a deletion.
    2. 14 |
  2. 15 |
  3. This was a substitution.
  4. 16 |
  5. This is a highlight.
  6. 17 |
  7. This is a highlight without comment.
  8. 18 |
19 | -------------------------------------------------------------------------------- /tests-ref/test-7.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 129 | 130 | 131 |
    132 |
  • Markup
  • 133 |
  • Original
  • 134 |
  • Edited
  • 135 |
136 | 137 | 138 | 139 | 140 | 193 | 194 | 195 | 196 | 197 | 198 | 199 |
200 | 201 |

Cum sociis natoque penatibus et magnisFTP - 2013-05-13 08:20:18 dis parturient montes, nascetur ridiculus mus. Praesent et tellus in eros cunning FTP - 2013-05-13 08:20:22eleifend imperdiet non at magna. Nunc aliquam accumsan auctor. In vitae mi sapien. Ut eget pretium purus. ProinPrawnFTP - 2013-05-13 08:20:29 condimentum hendrerit risus quis tristique. Cras fermentum, diam id sodales feugiat, arcu risus imperdiet nisi, sit amet consequat diam lectus id mi. Cras varius convallis turpis, in iaculis mi cursus vitae. Nulla dignissim aliquet nulla, eu pulvinar nunc fringilla ut. Nullam condimentum tortorHuh? eu quam tempor tempus. Quisque sit amet magna nec nisl mollis varius a nec ligula. Sed adipiscing, est in gravida sagittis, elit sapien vestibulum quam, a Test comment.tristique arcu eros nec enim. Morbi euismod velit eget ligula faucibus quis feugiat massa fermentum. In velit tellus, pretium ac posuere ac, ultrices eget magna.

202 |
    203 |
  1. This is an addition.
  2. 204 |
  3. This was a deletion.
  4. 205 |
  5. This wasis a substitution.
  6. 206 |
  7. This is a highlight With a comment that should not appear..
  8. 207 |
  9. This is a highlight without comment.
  10. 208 |
209 | 210 |
211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /tests-ref/test-8.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Untitled 8 | 14 | 17 | 18 | 19 | No output file extension nor to-format specified. Default to HTML. 20 | 142 | 143 | 196 |
197 |

198 | Cum sociis natoque penatibus et magnisFTP - 2013-05-13 08:20:18 dis parturient montes, nascetur ridiculus mus. Praesent et tellus in eros cunning FTP - 2013-05-13 08:20:22eleifend imperdiet non at magna. Nunc aliquam accumsan auctor. In vitae mi sapien. Ut eget pretium purus. ProinPrawnFTP - 2013-05-13 08:20:29 condimentum hendrerit risus quis tristique. Cras fermentum, diam id sodales feugiat, arcu risus imperdiet nisi, sit amet consequat diam lectus id mi. Cras varius convallis turpis, in iaculis mi cursus vitae. Nulla dignissim aliquet nulla, eu pulvinar nunc fringilla ut. Nullam condimentum tortorHuh? eu quam tempor tempus. Quisque sit amet magna nec nisl mollis varius a nec ligula. Sed adipiscing, est in gravida sagittis, elit sapien vestibulum quam, a Test comment.tristique arcu eros nec enim. Morbi euismod velit eget ligula faucibus quis feugiat massa fermentum. In velit tellus, pretium ac posuere ac, ultrices eget magna. 199 |

200 |
    201 |
  1. 202 | 203 | This is an addition. 204 | 205 |
  2. 206 |
  3. 207 | 208 | This was a deletion. 209 | 210 |
  4. 211 |
  5. 212 | This wasis a substitution. 213 |
  6. 214 |
  7. 215 | This is a highlight With a comment that should not appear.. 216 |
  8. 217 |
  9. 218 | This is a highlight without comment. 219 |
  10. 220 |
221 |
222 | 223 | 224 | -------------------------------------------------------------------------------- /tests.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Test CriticMarkup with pandoc 3 | author: Kolen Cheung 4 | fontfamily: lmodern,changes 5 | --- 6 | 7 | Cum sociis natoque {--penatibus et magnis--}{>>FTP - 2013-05-13 08:20:18<<} dis parturient montes, nascetur ridiculus mus. Praesent et tellus in eros {++cunning ++}{>>FTP - 2013-05-13 08:20:22<<}eleifend imperdiet non at magna. Nunc aliquam accumsan auctor. In vitae mi sapien. Ut eget pretium purus. {~~Proin~>Prawn~~}{>>FTP - 2013-05-13 08:20:29<<} condimentum hendrerit risus quis tristique. Cras fermentum, diam id sodales feugiat, arcu risus imperdiet nisi, sit amet consequat diam lectus id mi. Cras varius convallis turpis, in iaculis mi cursus vitae. Nulla dignissim aliquet nulla, eu pulvinar nunc fringilla ut. Nullam {==condimentum tortor==}{>>Huh?<<} eu quam tempor tempus. Quisque sit amet magna nec nisl mollis varius a nec ligula. Sed adipiscing, est in gravida sagittis, elit sapien vestibulum quam, a {>>Test comment.<<}tristique arcu eros nec enim. Morbi euismod velit eget ligula faucibus quis feugiat massa fermentum. In velit tellus, pretium ac posuere ac, ultrices eget magna. 8 | 9 | 1. {++This is an *addition*.++} 10 | 2. {--This was a *deletion*.--} 11 | 3. This {~~*was*~>*is*~~} a substitution. 12 | 4. This is a {==*highlight*==}{>> With a *comment* that should not appear.<<}. 13 | 5. This is a {==*highlight*==} without comment. 14 | --------------------------------------------------------------------------------