Metadata-Version: 2.5
Name: latexwalker
Version: 0.1.0
Summary: Parse LaTeX source and emit it in a canonical, normalized form
Project-URL: Homepage, https://github.com/pzarczynski/latexwalker
Author-email: pzarczynski <piotr.zarczynski.06@gmail.com>
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.12
Requires-Dist: msgspec[yaml]>=0.21.1
Description-Content-Type: text/markdown

# 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

```python
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`.

```python
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](CONTRIBUTING.md) for setup instructions
(`just setup`) and workflow. Architecture notes live in
[ARCHITECTURE](ARCHITECTURE.md); agent-facing conventions in
[AGENTS](AGENTS.md).

## License

MIT
