Expand description
A fast, zero-copy CommonMark parser with SIMD-accelerated scanning.
marki-parse parses Markdown into structured Section and Inline elements,
borrowing directly from the input string with no intermediate allocations for
text content.
§Quick start
use marki_parse::MarkdownFile;
let md: MarkdownFile<'_> = MarkdownFile::parse("# Hello\n\nSome **bold** text.");
for section in &md.sections {
println!("{section:?}");
}§CRLF input
The parser operates on LF (\n) line endings. For input that may contain
\r\n, call MarkdownFile::normalize first — it returns the input borrowed when no
\r is present (zero cost):
let input = "# Hello\r\nWorld";
let normalized = marki_parse::MarkdownFile::normalize(input);
let md: marki_parse::MarkdownFile<'_> = marki_parse::MarkdownFile::parse(&normalized);§Accessing inline elements
Inline elements are stored in a flat pool for cache efficiency. Use
MarkdownFile::inlines and MarkdownFile::item_spans (or index with
InlineSpan / SpanSlice) to retrieve them:
use marki_parse::{MarkdownFile, Section};
let md: MarkdownFile<'_> = MarkdownFile::parse("Hello **world**");
if let Some(Section::Paragraph { content }) = md.sections.first() {
for inline in md.inlines(*content) {
println!("{inline:?}");
}
}Structs§
- Inline
Span - A range of inline elements stored contiguously in the inline pool.
- Markdown
File - A parsed Markdown document.
- Span
Slice - A range of
InlineSpanelements stored contiguously in the span pool. Used by list sections to avoid per-listVec<InlineSpan>heap allocations.
Enums§
- Inline
- An inline element within a Markdown block.
- Ordered
List Delimiter - The delimiter used after the number in an ordered list item (
1.vs1)). - Section
- A block-level element of a Markdown document.
- Special
Char