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
fmt - Source-canonicalising formatter algorithm.
- json
json - Driver-shared wire format for serialising
aozoraparser output. - pandoc
pandoc - Pandoc AST projection — emit a
pandoc_ast::Pandocdocument consumable by every Pandoc output format (HTML, EPUB, LaTeX/PDF, DOCX, …). Aozora → Pandoc AST projection.
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. Introspected metadata for a diagnostic code — the machine axes plus the language-neutral example data behindaozora explain <code>. - Directive
View - Borrowed view of a parsed literal or editorial directive.
- Document
- Single owning handle to a parsed Aozora source.
- Gaiji
Resolution - One resolved gaiji reference located in source.
- 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. Resolved open/close pair, as observed by the pair stage. - Parser
- Configurable parser for Aozora source.
- Render
Options - Options controlling the opt-in HTML render path.
- Ruby
View - Borrowed projection of a ruby annotation.
- Serialize
Options - Options controlling how the AST is re-emitted 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. Both endpoints are guaranteed to fall on UTF-8 character boundaries when produced by the parser; callers can safely slice the source with them. - Text
Edit - A byte-range replacement against a document’s current UTF-8 source.
Enums§
- Catalogue
Family - Family / coarse category a slug belongs to. Used by the LSP
completion UI to group entries (
CompletionItem::sort_text) and pick an appropriateCompletionItemKindicon. - Catalogue
Match - Notation-hygiene normalization tier for a directive body.
- Container
Kind - Stable family tag for a paired block container.
- Decode
Error - Errors surfaced by the decode pipeline.
- 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. Origin of aDiagnostic— distinguishes user-input issues from library-internal sanity-check failures. - Directive
Class - Stable classification for a literal or editorial directive.
- Directive
Normalization - Which notation-hygiene catalogue tiers a serialize / render pass consults
when it meets a
DirectiveKind::Editorialnear-miss. - 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 of a specific pipeline-internal sanity check. - Literal
Markup Kind - Stable category for notation-shaped text with no parser semantics.
- Node
Kind - Cross-cutting tag for an AST node or
NodeRefprojection. - 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. Pair kind. The variants enumerate every balanced delimiter Aozora notation recognises. - Parse
Error - Failure to accept parser input.
- Ruby
Side - Which side of the base text a ruby reading sits on.
- 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 - Every CSS class token the HTML renderer can emit.
Functions§
- decode_
auto - Decode Aozora source bytes to UTF-8, detecting the encoding.
- decode_
auto_ into - Encoding-agnostic counterpart to
decode_sjis_into: append the decoded UTF-8 todst, detecting the source encoding. - decode_
sjis - Decode a
Shift_JISbyte slice into UTF-8 (NFC normalisation is applied by the caller after decoding). - decode_
sjis_ into - Decode a
Shift_JISbyte slice into the caller-owneddstbuffer. - diagnostics_
text - Plain-text diagnostic rendering (
miette-free, every target). Renderdiagnosticsoversourceas a plain-text report. - has_
utf8_ bom - Whether the byte slice carries a UTF-8 BOM (
EF BB BF). - 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.