TexSoup
TexSoup is a fault-tolerant, Python3 package for searching, navigating, and modifying LaTeX documents. You can skip installation and try TexSoup directly, using the pytwiddle demo →
Created by Alvin Wan + contributors.
Getting Started
To parse a $LaTeX$ document, pass an open filehandle or a string into the
TexSoup constructor.
from TexSoup import TexSoup
soup = TexSoup("""
\begin{document}
\section{Hello \textit{world}.}
\subsection{Watermelon}
(n.) A sacred fruit. Also known as:
\begin{itemize}
\item red lemon
\item life
\end{itemize}
Here is the prevalence of each synonym.
\begin{tabular}{c c}
red lemon & uncommon \\
life & common
\end{tabular}
\end{document}
""")
With the soupified $\LaTeX$, you can now search and traverse the document tree. The code below demonstrates the basic functions that TexSoup provides.
>>> soup.section # grabs the first `section`
\section{Hello \textit{world}.}
>>> soup.section.name
'section'
>>> soup.section.string
'Hello \\textit{world}.'
>>> soup.section.parent.name
'document'
>>> soup.tabular
\begin{tabular}{c c}
red lemon & uncommon \\
life & common
\end{tabular}
>>> soup.tabular.args[0]
'c c'
>>> soup.item
\item red lemon
>>> list(soup.find_all('item'))
[\item red lemon, \item life]
For more use cases, see the Quickstart Guide. Or, try TexSoup online, via pytwiddle →
Links:
- Quickstart Guide: how and when to use TexSoup
- Example Use Cases: counting references, resolving imports, and more
Installation
Pip
TexSoup is published via PyPi, so you can install it via pip. The package
name is TexSoup:
$ pip install texsoup
From source
Alternatively, you can install the package from source:
$ git clone https://github.com/alvinwan/TexSoup.git
$ cd TexSoup
$ pip install .
Metadata
Release files for TexSoup 0.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| texsoup-0.3.3.tar.gz | 41.4 kB | Without provenance | Details for texsoup-0.3.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| texsoup-0.3.3-py3-none-any.whl | Python 3 | none | any | Details for texsoup-0.3.3-py3-none-any.whl |
Total release size: 74.7 kB
Release files / texsoup-0.3.3.tar.gz
| Download URL | texsoup-0.3.3.tar.gz |
|---|---|
| Size | 41.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a3e22b61ce890a602eed006c80119f64b1697e48e39f13c0b094c2efc1dc1abf
|
|
BLAKE2b-256 checksum How to use checksums |
9a87e15640e4a12579a70d764f45953f3fab07a5c7e8923e77904837966ffd57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Release files / texsoup-0.3.3-py3-none-any.whl
| Download URL | texsoup-0.3.3-py3-none-any.whl |
|---|---|
| Size | 33.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0ad8643f7b51a4903de87c3763a090343fc73eaf87cd70202e2bfe6b22e0ac97
|
|
BLAKE2b-256 checksum How to use checksums |
0d60388c55709eccb28c4245bd809fada603905e09507b722f0a7e0065beb8f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Security for TexSoup 0.3.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.