Skip to main content

Crate aozora

Crate aozora 

Source
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

§License

Apache-2.0 OR MIT, at your option.

Modules§

fmt
Source-canonicalising formatter algorithm.
json
Driver-shared wire format for serialising aozora parser output.
pandoc
Pandoc AST projection — emit a [pandoc_ast::Pandoc] document consumable by every Pandoc output format (HTML, EPUB, LaTeX/PDF, DOCX, …). Aozora → Pandoc AST projection.

Structs§

Catalogue
Canonical directive metadata used by editor integrations.
CatalogueEntry
One row of the slug catalogue.
ContainerPair
Paired container markers in source coordinates.
DiagnosticInfo
Canonical diagnostic / span / pair types — the single definitions live in the crate-internal spec module; re-exported here as the stable crate-root facade. Introspected metadata for a diagnostic code — the machine axes plus the language-neutral example data behind aozora explain <code>.
DirectiveView
Borrowed view of a parsed literal or editorial directive.
Document
Single owning handle to a parsed Aozora source.
GaijiResolution
One resolved gaiji reference located in source.
LiteralMarkupView
Stable projection of notation-shaped text preserved literally.
NodeView
Stable projection of a parsed node.
PairLink
Canonical diagnostic / span / pair types — the single definitions live in the crate-internal spec module; 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.
RenderOptions
Options controlling the opt-in HTML render path.
RubyView
Borrowed projection of a ruby annotation.
SerializeOptions
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 spec module; 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.
TextEdit
A byte-range replacement against a document’s current UTF-8 source.

Enums§

CatalogueFamily
Family / coarse category a slug belongs to. Used by the LSP completion UI to group entries (CompletionItem::sort_text) and pick an appropriate CompletionItemKind icon.
CatalogueMatch
Notation-hygiene normalization tier for a directive body.
ContainerKind
Stable family tag for a paired block container.
DecodeError
Errors surfaced by the decode pipeline.
Diagnostic
Canonical diagnostic / span / pair types — the single definitions live in the crate-internal spec module; re-exported here as the stable crate-root facade. Observation emitted by any lexer stage.
DiagnosticSource
Canonical diagnostic / span / pair types — the single definitions live in the crate-internal spec module; re-exported here as the stable crate-root facade. Origin of a Diagnostic — distinguishes user-input issues from library-internal sanity-check failures.
DirectiveClass
Stable classification for a literal or editorial directive.
DirectiveNormalization
Which notation-hygiene catalogue tiers a serialize / render pass consults when it meets a DirectiveKind::Editorial near-miss.
EditError
Failure to apply one or more text edits.
InternalCheckCode
Canonical diagnostic / span / pair types — the single definitions live in the crate-internal spec module; re-exported here as the stable crate-root facade. Identifier of a specific pipeline-internal sanity check.
LiteralMarkupKind
Stable category for notation-shaped text with no parser semantics.
NodeKind
Cross-cutting tag for an AST node or NodeRef projection.
PairKind
Canonical diagnostic / span / pair types — the single definitions live in the crate-internal spec module; re-exported here as the stable crate-root facade. Pair kind. The variants enumerate every balanced delimiter Aozora notation recognises.
ParseError
Failure to accept parser input.
RubySide
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 spec module; re-exported here as the stable crate-root facade. Severity of a Diagnostic.

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 to dst, detecting the source encoding.
decode_sjis
Decode a Shift_JIS byte slice into UTF-8 (NFC normalisation is applied by the caller after decoding).
decode_sjis_into
Decode a Shift_JIS byte slice into the caller-owned dst buffer.
diagnostics_text
Plain-text diagnostic rendering (miette-free, every target). Render diagnostics over source as 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.