Skip to main content

TexSoup

PyPi Downloads per Day Build Status Coverage Status

TexSoup is a fault-tolerant, Python3 package for searching, navigating, and modifying LaTeX documents.

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 repl.it →

Links:

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 .

Release files for texsoup-alt 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for texsoup-alt 0.3.1
File Size Uploaded
texsoup-alt-0.3.1.tar.gz 34.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for texsoup-alt 0.3.1
File Interpreter ABI Platform
texsoup_alt-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 62.0 kB

Release files / texsoup-alt-0.3.1.tar.gz

Download URL texsoup-alt-0.3.1.tar.gz
Size 34.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0007e921b694d834772c0749241f7a329aaf9625b8532d5839b03f73e4e09af9
BLAKE2b-256 checksum
How to use checksums
47a4f232e754175eb00ac899924567be96c9bbab9a3cce32b8ed8c630ec843c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.7

Release files / texsoup_alt-0.3.1-py3-none-any.whl

Download URL texsoup_alt-0.3.1-py3-none-any.whl
Size 27.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a6bb85be60f61bc0ca2744c95be7c103ddc6895bc92f93aac8e688c9631ef15
BLAKE2b-256 checksum
How to use checksums
c463e31fc1f7e7bb62d31fcfaebd65601cf220f72d25cff23af6c17da2e48da3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.7

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page