P0 baseline: one Markdown parser, one frozen option set, no silent upgrades. - profile: CommonMark 0.31.2 core + GFM tables/strikethrough/task lists + dollar math + YAML front matter at byte 0, with every other extension disabled and asserted by tests. comrak is pinned to exactly 1.0.0. - ast::MdNode: owned, serializable node tree carrying kind, byte Span and literal payloads. Nodes outside the profile are preserved as MdKind::Other instead of being dropped; task list items keep their checkbox state. - frontmatter: extracts the YAML body from the parser node, parses it once, and exposes only the explicit `import` alias mapping; invalid YAML is reported, never guessed. - text: strict executable payload extraction (Text/Code only, everything else is a hard error) and inert plain-text extraction for heading names. - UTF-8 BOM is tolerated; all spans are re-based onto the original file. No semantic mapping or execution exists in this crate by design.
20 lines
802 B
Rust
20 lines
802 B
Rust
//! Canonical Markdown AST for Marqdo.
|
|
//!
|
|
//! This crate is the only place that talks to the Markdown parser. It freezes
|
|
//! the CommonMark/GFM/Math profile (see [`profile`]), converts the parser tree
|
|
//! into an owned [`ast::MdNode`] tree with byte spans, and extracts YAML front
|
|
//! matter. It performs **no** semantic mapping and **no** execution: deciding
|
|
//! which AST nodes are executable is the frontend's job and is based on the
|
|
//! node kind and structural position only.
|
|
|
|
pub mod ast;
|
|
pub mod frontmatter;
|
|
pub mod profile;
|
|
pub mod text;
|
|
|
|
pub use ast::{MdKind, MdNode};
|
|
pub use frontmatter::FrontMatter;
|
|
pub use marqdo_span::{LineCol, Span};
|
|
pub use profile::{parse, MarkdownDocument, COMRAK_VERSION, PROFILE_ID};
|
|
pub use text::{executable_payload, normalize_name, plain_text, PayloadError};
|