GitXplorerGitXplorer
o

inpytex

public
4 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
87f8f8bcaeda0154e1bd3d89a90c9e36d0a31772

Better error reporting, fix bug in setup.py, explain labels in README

oot committed 12 years ago
Unverified
fa7856d794b391070298da5e05a6c54f25e1e5a0

Add README, rename script

oot committed 12 years ago
Unverified
9acd2b724c3884a3d3082102ff26bfbd1f981eea

Added setup.py

committed 16 years ago
Unverified
d52e1180bf639ba50c4809a80f5bd95569330a6d

Added emacs utilities to switch mode

committed 16 years ago
Unverified
48f253139cf370ea59c3180b47b9d620eced72fc

New parsing, compute checksum of autogenerated code

committed 16 years ago
Unverified
4e13139dae483dff09dd6b0c78fd4eedbd33195f

Added MD5 checksum

committed 16 years ago

README

The README file for this repository.

inpytex

inpytex is a Python-based pre-processor for (La)TeX files. It executes Python snippets in comments and inserts their output under the comment.

For example, the following LaTeX file:

\begin{itemize}
   %%% inpytex My first snippet
   % >>> for i in range(3):
   % ...     emit('\item %s' % i)
   %%% end
\end{itemize}

inpytex recognizes Python snippets that are enclosed between %%% inpytex and %%% end, and written in the doctest syntax (so that there is no indentation ambiguity). A label (as My first snippet above) can be added after %%% inpytex to recognize the snippet in the script log.

By running inpytex on the file, the snippet gets expanded into the following:

\begin{itemize}
   %%% inpytex My first snippet
   % >>> for i in range(3):
   % ...     emit('\item %s' % i)
   %%% AUTOGENERATED, DO NOT EDIT UNTIL "%%% end"
   \item 0
   \item 1
   \item 2
   %%% end 99490253c65b69eb7112445388fb1c21
\end{itemize}

Note that the file is modified in-place, so you may want to commit the file to a VCS before running inpytex. The rationale behind this behavior is the following:

  • The Python snippet serves as a comment describing the auto-generated code below it. Also, it is less likely that the Python snippet and the generated code will lose sync.

  • Once inpytex is run on the file, it is not needed anymore unless the snippets are changed. This is useful when working with other people.

If the python snippets are modified, the generated code is overwritten. However, if the generated code is modified manually, inpytex detects it by checking the checksum after end, and it refuses to overwrite the code. To force overwriting, just remove the checksum.

Important note

This script was written while working on my master's thesis to automate the creation of some TiKz figures and tables. It has not been used or maintained since then (except minor cosmetic changes). Use it at your own risk.