Recipes
Task-shaped, copy-paste answers to “how do I do X with aozora?”. Each recipe is a single problem stated in one sentence, the minimal correct code to solve it, the output you should expect, and a jump list to the deeper chapters.
The Rust snippets use the umbrella aozora
crate and nothing else — downstream consumers depend on aozora
alone, never the internal build-block crates. The shell snippets use
the aozora binary. If you have not yet got either
in scope, start at Install, then the
Library or
CLI quickstart.
Each recipe that has a Rust solution maps to a runnable example under
crates/aozora/examples/, so you can read the whole program and run
it rather than reassembling fragments. Where that applies the recipe
says so — e.g. run with just example walk_ast.
The recipes
| I want to… | Recipe |
|---|---|
| Pull every ruby base + reading pair out of a document | Extract ruby pairs |
| Get diagnostics as machine-readable JSON | Diagnostics as JSON |
| Walk the parsed tree node by node | Walk the AST |
| Parse a Shift_JIS file and resolve 外字 | Shift_JIS & gaiji |
| Convert to EPUB / LaTeX / DOCX | EPUB via Pandoc |
| Check that a file is already canonical | Round-trip & fmt –check |
| Call aozora from Go / Java / Python / JS | Call from another language |
The example programs
The recipes mirror these runnable examples (authored under
crates/aozora/examples/); each is launched with just example <name>:
| Example | Mirrors |
|---|---|
hello | The six-line render in the Library quickstart |
walk_ast | Walk the AST, Extract ruby pairs |
diagnostics | Diagnostics as JSON |
round_trip | Round-trip & fmt –check |
sjis | Shift_JIS & gaiji |
See also
- Library Quickstart — the lifetime
model and the core
Document→AozoraTreeflow every recipe assumes. - Choosing a binding — picking the surface (Rust / CLI / wasm / Python / Go / Extism) before you start.
- Node reference — what each AST node represents.
- Wire format — the JSON envelope the
aozora::wireserialisers emit.