Skip to main content

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

latexwalker-0.1.0.tar.gz (96.2 kB view details)

Uploaded Source

Built Distribution

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

latexwalker-0.1.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

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

Hashes for latexwalker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4400ba034bcd5e8395c94b3b5ae5ecaec663c5888037cd9c08b760afc15d2c63
MD5 b93c74058760e5ab2f64130b9d54a884
BLAKE2b-256 3cf6b6ec9c177912bb722eaa6f3926d35b61729c4bc5982b1ad42b5340dd097a

See more details on using hashes here.

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

Hashes for latexwalker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ab9789b0b76aee73ffdcea7670ff8f0cec1f60259a47ef730c6148789df576d
MD5 15a78efed9885883378603c9f3929003
BLAKE2b-256 c15a6e8d426451c18b7555054195623de64470aecb4505e48d18b759f7c569d5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 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