Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

nzbr/pandocode

Repository files navigation

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 typepseudo to LaTeX

Run:
pandoc --filter /path/to/pandocode.pyz <infile.md> -o <outfile>
or
pandoc --filter pandocode <infile.md> -o <outfile>

Building

  • Install dependencies fromrequirements.txt andmake-requirements.txt
    • pip3 install -r requirements.txt -r make-requirements.txt
    • orpip3 install --user -r requirements.txt -r make-requirements.txt
  • Runmake
  • Optional: Runsudo make install
    • This will installpandocode.pyz to/usr/bin/pandocode

Use PyPy3 instead of CPython

  • Usepypy3 -m pip instead ofpip3
    • If pip is missing, install it withpypy3 -m ensurepip orpypy3 -m ensurepip --user
  • Runmake PY=pypy3 instead ofmake

Without PyLint:

If you want to build without running pylint:

  • Don't installmake-requirements.txt
  • Runmake PYLINT=$(which true) instead ofmake

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 withpandoc-include-code

---header-includes:  - \usepackage[noend]{algpseudocode}---```{.pseudo include=code.py}```

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp