Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nzbr/pandocode

Pandocode is a program/pandoc-filter that converts Python(-like) code to LaTeX Pseudocode
https://github.com/nzbr/pandocode

code-converter education latex markdown pandoc pandoc-filter pseudocode pseudocode-generator pypy pypy3 python python3

Last synced: 20 days ago
JSON representation

Pandocode is a program/pandoc-filter that converts Python(-like) code to LaTeX Pseudocode

Awesome Lists containing this project

README

        

# Pandocode

`pandocode` is a pandoc filter that converts Python _(-like)_ code to LaTeX-Pseudocode.
It can also be used as a standalone program.

## [Try it in your browser](https://pandocode.nzbr.de)

## Usage

### Standalone
Outputs the resulting LaTeX code to console

**Run:**
`./pandocode.pyz `
or
`pandocode `

### Filter
Converts every code-block of type _pseudo_ to LaTeX

**Run:**
`pandoc --filter /path/to/pandocode.pyz -o `
or
`pandoc --filter pandocode -o `

## Building
- Install dependencies from `requirements.txt` and `make-requirements.txt`
- `pip3 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.pyz` to `/usr/bin/pandocode`

#### Use PyPy3 instead of CPython
- Use `pypy3 -m pip` instead of `pip3`
- If pip is missing, install it with `pypy3 -m ensurepip` or `pypy3 -m ensurepip --user`
- Run `make PY=pypy3` instead of `make`

#### Without PyLint:
If you want to build without running pylint:
- Don't install `make-requirements.txt`
- Run `make PYLINT=$(which true)` instead of `make`

## Examples

[There is an example in the demo directory](https://github.com/nzbr/pandocode/tree/master/demo)

## Control sequences
Pandocode allows the use of the following control sequences inside the code:

#### Begin/End
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.

#### Add
Syntax:
- `#$+ `

Includes `` as a line in the code before code processing.

#### Remove
Syntax:
- `#$-`

Removes the next line before code processing.

#### Replace
Syntax:
- `#$= `

Replaces the next line by `` before code processing.

#### Raw
Syntax:
- `:: `

When encountered during processing, instead of processing this line, `:: ` gets removed and `` is appended to the output.
This can be used as `` in any control sequence that is processed before code processing.

Example:
`#$= :: `
Replaces the next line by raw LaTeX

## External Code

Pandocode is tested to be working with [pandoc-include-code](https://github.com/owickstrom/pandoc-include-code)

---
header-includes:
- \usepackage[noend]{algpseudocode}
---

```{.pseudo include=code.py}
```