Skip to main content

Crate afm_markdown

Crate afm_markdown 

Source
Expand description

Aozora Flavored Markdown — CommonMark + GFM + 青空文庫記法.

Layers aozora-pipeline (青空文庫記法 borrowed-AST lexer) onto a vendored verbatim comrak so a single render_to_string call turns afm source into HTML. Public entry points:

§Pipeline

source                                   ── UTF-8 input
  │
  ▼ aozora_pipeline::lex_into_arena      ── normalized text + Registry
  │
  ▼ comrak::parse_document               ── vanilla CommonMark + GFM
  │   (PUA sentinels U+E001..U+E004 flow through as plain text)
  │
  ▼ comrak::format_html_with_options     ── HTML with sentinels
  │
  ▼ post_process::splice_aozora_html     ── sentinel → aozora-render
  │   · INLINE_SENTINEL → render_node::render output
  │   · BLOCK_LEAF paragraphs → leaf node HTML
  │   · BLOCK_OPEN/CLOSE paragraphs → container open/close
  │
  ▼
HTML

Comrak is unmodified: the v0.52.0 verbatim tree carries no Aozora-aware code (ADR-0001 budget = 0).

Modules§

code_block_mask 🔒
Pre-/post-process pass that hides 青空文庫 trigger characters inside CommonMark fenced code blocks.
html
HTML rendering convenience entry.
ir
Intermediate representation produced by crate::render_to_ir.
post_process 🔒
HTML post-processing: splice Aozora sentinels into rendered comrak HTML.
sentinels 🔒
Shared primitives for both crate::post_process (HTML splicer) and crate::ir (IR builder).
source_line_anchors 🔒
Source-line anchor injection for the HTML renderer.

Structs§

Options
Parse-time configuration for render_to_string and friends.
Rendered
Output of render_to_string.
RenderedBlock
One block of render_blocks_to_ir’s output.
RenderedIr
Output of render_to_ir.

Enums§

Diagnostic
Observation emitted by any lexer phase.
DiagnosticSource
Origin of a Diagnostic — distinguishes user-input issues from library-internal sanity-check failures.
Severity
Severity of a Diagnostic.

Constants§

BLOCK_CLOSE_SENTINEL
Paired-container close line (e.g. [#ここで字下げ終わり]).
BLOCK_LEAF_SENTINEL
Block-leaf Aozora line (page break, section break, leaf indent, sashie).
BLOCK_OPEN_SENTINEL
Paired-container open line (e.g. [#ここから字下げ]).
INLINE_SENTINEL
Inline Aozora span (ruby / bouten / annotation / gaiji / TCY / kaeriten).

Functions§

collect_rendered_blocks 🔒
render_blocks_to_ir
Per-block streaming render.
render_to_ir
Render afm source to a structured IR + HTML + diagnostics.
render_to_string
Render afm source text to HTML.
serialize
Round-trip an afm source through the lexer and back to canonical afm-source text.