Giter Club home page Giter Club logo

pandocode's Introduction

Pandocode

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

Usage

Standalone

Outputs the resulting LaTeX code to console

Run:
./pandocode.pyz <file>
or
pandocode <file>

Filter

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>

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

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:

  • #$+ <text>

Includes <text> as a line in the code before code processing.

Remove

Syntax:

  • #$-

Removes the next line before code processing.

Replace

Syntax:

  • #$= <text>

Replaces the next line by <text> before code processing.

Raw

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

External Code

Pandocode is tested to be working with pandoc-include-code

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

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

pandocode's People

Contributors

dependabot[bot] avatar nzbr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

amanda246

pandocode's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.