Ipelet to format source code snippets in Ipe documents using Pygments.
A popular option to format source code in LaTeX documents is the minted package, which uses Pygments internally.
Unfortunately, this requires latex to be run with the -shell-escape
option, which is currently not possible in Ipe.
This ipelet sidesteps this problem by interacting with Pygments directly from within Ipe.
Besides Ipe, you will need a Python version with Pygments installed.
Copy the pygments.lua
file to your ipelet directory.
Then, in your preferred place, set the following two preference entries:
prefs.pygments = {
pygmentize = '/path/to/pygmentize',
python = '/path/to/python',
}
The latter must point to the Python interpreter that has Pygments installed.
There are three actions provided under Ipelets -> Pygments
:
- Format: formats the text in the selected text object.
After this, you will have to run LaTeX to view the result (
Ctrl-L
/Cmd-L
orFile -> Run Latex
). Running LaTeX from within the ipelet is possible but unfortunately results in a segmentation fault, crashing Ipe entirely. - Edit: opens a dialog allowing you to edit both the source code and language for the selected text object.
- Revert: reverts the content of the selected text object back to just the plain source code.