Skip to main content

Crate marki_parse

Crate marki_parse 

Source
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§

InlineSpan
A range of inline elements stored contiguously in the inline pool.
MarkdownFile
A parsed Markdown document.
SpanSlice
A range of InlineSpan elements stored contiguously in the span pool. Used by list sections to avoid per-list Vec<InlineSpan> heap allocations.

Enums§

Inline
An inline element within a Markdown block.
OrderedListDelimiter
The delimiter used after the number in an ordered list item (1. vs 1)).
Section
A block-level element of a Markdown document.
SpecialChar