Skip to main content

parses valid LaTeX and provides variety of Beautiful-Soup-esque methods and Pythonic idioms for iterating over and searching the parse tree

Project description

TexSoup

PyPi Downloads per Day Build Status Coverage Status

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:

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 .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

texsoup-0.3.2.tar.gz (38.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

texsoup-0.3.2-py3-none-any.whl (30.4 kB view details)

Uploaded Python 3

File details

Details for the file texsoup-0.3.2.tar.gz.

File metadata

  • Download URL: texsoup-0.3.2.tar.gz
  • Upload date:
  • Size: 38.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for texsoup-0.3.2.tar.gz
Algorithm Hash digest
SHA256 2da4480985c7b88b7c01418f6b02821140390fe9db63dfd993eac0084c1853fa
MD5 f906336aff8dea1daffa7ee0501992ad
BLAKE2b-256 520894ba9203740c410d89d4655b69efd1816492676e656ba69371d49c6d6aa3

See more details on using hashes here.

File details

Details for the file texsoup-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: texsoup-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 30.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for texsoup-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e5bbb9816a60075693b8af7876d04b830ff2080ce8db76931327f4071625055f
MD5 93d52028953b07223c624c920bf9d86e
BLAKE2b-256 a2f72b8bf90d67002701cefa3ad95eabf078315342d41527795985644117ddd5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page