Expand description
aozora — the public meta crate.
Single front door for parsing Aozora Bunko notation. Downstream
consumers should depend on this crate alone; everything they need
is re-exported through this surface or accessed via Document
and Snapshot.
use aozora::parse;
let doc = parse("|青空《あおぞら》文庫")?;
let snapshot = doc.snapshot();
let html = snapshot.to_html();
assert!(html.contains("青空")); // the ruby base survives into the HTML§Architecture
Document owns the source and incremental parse state.
Document::snapshot returns an immutable, owned Snapshot that
is Clone + Send + Sync.
The parsing and rendering implementation is private. Consumers use the
crate-root façade: Parser, Document, immutable Snapshot,
original-source spans and stable projection views. The feature-gated
json module is the only public low-level wire surface.
The crate README follows; its Quickstart example is compiled as a doctest so it can never drift from the live API.
§aozora
A parser for 青空文庫記法 (Aozora Bunko notation). Reads Shift_JIS or UTF-8; emits HTML, JSON, or canonical source.
use aozora::parse;
let doc = parse("|青梅《おうめ》").expect("source fits parser limits");
let snapshot = doc.snapshot();
let html = snapshot.to_html();
let diagnostics = snapshot.diagnostics();Depend on this crate alone for parsing, diagnostics, rendering, and incremental editing.
§Documentation
- API reference — including which features gate what
- Examples
- Notation specification
- Playground — try it in the browser
§License
Apache-2.0 OR MIT, at your option.
Modules§
- fmt
- Source-canonicalising formatter algorithm.
- json
- Serializes parser projections as versioned JSON envelopes.
Each envelope contains
schemaVersionand adataarray. CheckSCHEMA_VERSIONbefore interpreting an envelope. - pandoc
- Pandoc AST projection — emit a [
pandoc_ast::Pandoc] document consumable by every Pandoc output format (HTML, EPUB, LaTeX/PDF, DOCX, …). Projects Aozora documents to Pandoc.
Structs§
- Catalogue
- Canonical directive metadata used by editor integrations.
- Catalogue
Entry - One row of the slug catalogue.
- Container
Pair - Paired container markers in source coordinates.
- Diagnostic
Info - Canonical diagnostic / span / pair types — the single definitions live in
the crate-internal
specmodule; re-exported here as the stable crate-root facade. Metadata and examples returned byDiagnostic::explain. - Directive
View - Borrowed view of a parsed literal or editorial directive.
- Document
- Single owning handle to a parsed Aozora source.
- Gaiji
Resolution - A source gaiji reference and its optional Unicode resolution.
- Literal
Markup View - Stable projection of notation-shaped text preserved literally.
- Node
View - Stable projection of a parsed node.
- Pair
Link - Canonical diagnostic / span / pair types — the single definitions live in
the crate-internal
specmodule; re-exported here as the stable crate-root facade. Matched delimiters with byte spans in the original source. - Parser
- Configurable parser for Aozora source.
- Render
Options - Options for HTML rendering.
- Ruby
View - Borrowed projection of a ruby annotation.
- Serialize
Options - Options for serializing a snapshot to Aozora source.
- Snapshot
- Immutable, cheaply cloneable parsed view.
- Span
- Canonical diagnostic / span / pair types — the single definitions live in
the crate-internal
specmodule; re-exported here as the stable crate-root facade. Byte-range span whose parser-produced endpoints lie on UTF-8 boundaries. - Text
Edit - A byte-range replacement against a document’s current UTF-8 source.
Enums§
- Catalogue
Family - Directive category for editor completion entries.
- Catalogue
Match - Notation-hygiene normalization tier for a directive body.
- Container
Kind - Stable family tag for a paired block container.
- Decode
Error - Errors from decoding source bytes.
- Diagnostic
- Canonical diagnostic / span / pair types — the single definitions live in
the crate-internal
specmodule; re-exported here as the stable crate-root facade. Observation emitted by any lexer stage. - Diagnostic
Source - Canonical diagnostic / span / pair types — the single definitions live in
the crate-internal
specmodule; re-exported here as the stable crate-root facade. Whether a diagnostic concerns user input or a library defect. - Directive
Class - Stable classification for a literal or editorial directive.
- Directive
Normalization - Directive normalization levels from ADR-0022 and ADR-0026.
- Edit
Error - Failure to apply one or more text edits.
- Internal
Check Code - Canonical diagnostic / span / pair types — the single definitions live in
the crate-internal
specmodule; re-exported here as the stable crate-root facade. Identifier for the check reported byDiagnostic::Internal. - Literal
Markup Kind - Stable category for notation-shaped text with no parser semantics.
- Node
Kind - Node kind emitted in parser projections and wire formats.
- Pair
Kind - Canonical diagnostic / span / pair types — the single definitions live in
the crate-internal
specmodule; re-exported here as the stable crate-root facade. Balanced delimiter family in Aozora notation. - Parse
Error - Failure to accept parser input.
- Ruby
Side - Placement of a ruby reading relative to its base text.
- Severity
- Canonical diagnostic / span / pair types — the single definitions live in
the crate-internal
specmodule; re-exported here as the stable crate-root facade. Severity of aDiagnostic.
Constants§
- AOZORA_
CLASSES - CSS classes that the HTML renderer can emit, sorted without duplicates.
Functions§
- decode_
auto - Decode source bytes, preferring UTF-8 over
Shift_JIS. - decode_
auto_ into - Append decoded source bytes to
dst, preferring UTF-8 overShift_JIS. - decode_
sjis - Decode
Shift_JISbytes to UTF-8 without replacing malformed sequences. - decode_
sjis_ into - Append decoded
Shift_JIStext todst. - diagnostics_
text - Plain-text diagnostic rendering (
miette-free, every target). Render diagnostics as plain text with source excerpts. - has_
utf8_ bom - Whether the input begins with the UTF-8 byte order mark.
- parse
- Parse source with default settings.
- prewarm
- Eagerly initialise the parser’s process-global lazy tables.
- resolve_
gaiji - Resolve one gaiji description and optional mencode to a glyph sequence.