pandocode is a pandoc filter that converts Python (-like) code to LaTeX-Pseudocode.
It can also be used as a standalone program.
Outputs the resulting LaTeX code to console
Run:
./pandocode.pyz <file>
or
pandocode <file>
Converts every code-block of type pseudo to LaTeX
Run:
pandoc --filter /path/to/pandocode.pyz <infile.md> -o <outfile>
or
pandoc --filter pandocode <infile.md> -o <outfile>
- Install dependencies from
requirements.txtandmake-requirements.txtpip3 install -r requirements.txt -r make-requirements.txt- or
pip3 install --user -r requirements.txt -r make-requirements.txt
- Run
make - Optional: Run
sudo make install- This will install
pandocode.pyzto/usr/bin/pandocode
- This will install
- Use
pypy3 -m pipinstead ofpip3- If pip is missing, install it with
pypy3 -m ensurepiporpypy3 -m ensurepip --user
- If pip is missing, install it with
- Run
make PY=pypy3instead ofmake
If you want to build without running pylint:
- Don't install
make-requirements.txt - Run
make PYLINT=$(which true)instead ofmake
There is an example in the demo directory
Pandocode allows the use of the following control sequences inside the code:
Syntax:
#$begin#$end
If a begin sequence is found, Pandocode ignores any code that is outside of a pair of begin/end control sequences.
If the end of the code is reached and no end sequence is encountered, all code from the begin sequence on is included.
Syntax:
#$+ <text>
Includes <text> as a line in the code before code processing.
Syntax:
#$-
Removes the next line before code processing.
Syntax:
#$= <text>
Replaces the next line by <text> before code processing.
Syntax:
:: <LaTeX>
When encountered during processing, instead of processing this line, :: gets removed and <LaTeX> is appended to the output.
This can be used as <text> in any control sequence that is processed before code processing.
Example:
#$= :: <LaTeX>
Replaces the next line by raw LaTeX
Pandocode is tested to be working with pandoc-include-code
---
header-includes:
- \usepackage[noend]{algpseudocode}
---
```{.pseudo include=code.py}
```