latexwalker
latexwalker is a Python library for parsing LaTeX source code into a syntax tree and re-emitting it in a canonical, normalized form. It turns messy, inconsistently formatted LaTeX into predictable, stable output — suitable for diffing, diff-friendly review, and downstream tooling.
The project is in early development -- pre-1.0; API may change.
Usage
from latexwalker import parse_document, walk
document = parse_document("Hello \\textbf{world}!")
for node in walk(document):
print(type(node).__name__, repr(document.source_of(node)))
parse_document never loses input detail: every node records the exact
source region it was built from, so document.source_of(document) returns
the original text byte-for-byte.
Normalization
normalize reduces messy LaTeX to a canonical form: formatting noise
(collapsed blanks, squeezed blank lines) disappears and equivalent
spellings fold onto one spelling — for example three spaced dot products
become \cdots, \rightarrow becomes \to.
from latexwalker import normalize
print(normalize(r"$\alpha \cdot \cdot \cdot \beta$"))
# $\alpha \cdots \beta$
Comments, verbatim-family environments, and math/text scoping boundaries
are respected automatically. The default rules live in
src/latexwalker/resources/rules.yaml; author your own file against
the same schema and pass it via normalize(text, rules=load_rules(path))
to replace them.
Development
See CONTRIBUTING for setup instructions
(just setup) and workflow. Architecture notes live in
ARCHITECTURE; agent-facing conventions in
AGENTS.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file latexwalker-0.1.0.tar.gz.
File metadata
- Download URL: latexwalker-0.1.0.tar.gz
- Upload date:
- Size: 96.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4400ba034bcd5e8395c94b3b5ae5ecaec663c5888037cd9c08b760afc15d2c63
|
|
| MD5 |
b93c74058760e5ab2f64130b9d54a884
|
|
| BLAKE2b-256 |
3cf6b6ec9c177912bb722eaa6f3926d35b61729c4bc5982b1ad42b5340dd097a
|
File details
Details for the file latexwalker-0.1.0-py3-none-any.whl.
File metadata
- Download URL: latexwalker-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ab9789b0b76aee73ffdcea7670ff8f0cec1f60259a47ef730c6148789df576d
|
|
| MD5 |
15a78efed9885883378603c9f3929003
|
|
| BLAKE2b-256 |
c15a6e8d426451c18b7555054195623de64470aecb4505e48d18b759f7c569d5
|