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
Serializes parser projections as versioned JSON envelopes. Each envelope contains schemaVersion and a data array. Check SCHEMA_VERSION before 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.
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. Metadata and examples returned by Diagnostic::explain.
DirectiveView
Borrowed view of a parsed literal or editorial directive.
Document
Single owning handle to a parsed Aozora source.
GaijiResolution
A source gaiji reference and its optional Unicode resolution.
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. Matched delimiters with byte spans in the original source.
Parser
Configurable parser for Aozora source.
RenderOptions
Options for HTML rendering.
RubyView
Borrowed projection of a ruby annotation.
SerializeOptions
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 spec module; re-exported here as the stable crate-root facade. Byte-range span whose parser-produced endpoints lie on UTF-8 boundaries.
TextEdit
A byte-range replacement against a document’s current UTF-8 source.

Enums§

CatalogueFamily
Directive category for editor completion entries.
CatalogueMatch
Notation-hygiene normalization tier for a directive body.
ContainerKind
Stable family tag for a paired block container.
DecodeError
Errors from decoding source bytes.
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. Whether a diagnostic concerns user input or a library defect.
DirectiveClass
Stable classification for a literal or editorial directive.
DirectiveNormalization
Directive normalization levels from ADR-0022 and ADR-0026.
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 for the check reported by Diagnostic::Internal.
LiteralMarkupKind
Stable category for notation-shaped text with no parser semantics.
NodeKind
Node kind emitted in parser projections and wire formats.
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. Balanced delimiter family in Aozora notation.
ParseError
Failure to accept parser input.
RubySide
Placement of a ruby reading relative to its base text.
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
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 over Shift_JIS.
decode_sjis
Decode Shift_JIS bytes to UTF-8 without replacing malformed sequences.
decode_sjis_into
Append decoded Shift_JIS text to dst.
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.