Skip to content
A simple demonstration of how to define a parser that converts latex mathmode delimiters
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
convert-delimiters.py add inline math mode to parser Apr 21, 2019
display-parsed-tree.py add inline math mode to parser Apr 21, 2019
regex_converter.sh
requirements.txt add lark-parser requirement Apr 20, 2019
test.tex

README.md

A Working Mathematician's Guide to Parsing

Associated blog post

This scripts requires a working Python installation (version 2 or 3).

To install the parser generator library Lark, run

pip install lark-parser

Then run the script in this repository (either by first copy/pasting its source to a file, or cloning the repository with git):

python convert-delimiters.py < file.tex > output.tex

Example input:

# test.tex
\begin{document}

This is a doc with $math$ in it. $ W o
W linebreak $

Now we have the following \[ offset equation \]

Now we have another $$
offset equation
$$ why would you use this one though

\end{document}

Example output:

\begin{document}

This is a doc with \(math\) in it. \( W o
W linebreak \)

Now we have the following \[ offset equation \]

Now we have another \[
offset equation
\] why would you use this one though

\end{document}
You can’t perform that action at this time.