Expand description
Markdown parser for CommonMark + GFM.
Parse Markdown text into an AST using parse_markdown.
Markdown parser for CommonMark + GitHub Flavored Markdown (GFM)
This module provides a comprehensive parser for Markdown documents following the CommonMark specification with GitHub Flavored Markdown extensions. The parser converts raw Markdown text into a fully-typed Abstract Syntax Tree (AST).
§Features
- CommonMark compliance: Full support for CommonMark 1.0 specification
- GitHub extensions: Tables, task lists, strikethrough, autolinks, footnotes, alerts
- Configurable parsing: Control which elements to parse, skip, or transform
- Custom parsers: Register custom block and inline element parsers
- Error handling: Comprehensive error reporting with nom-based parsing
§Basic Usage
use markdown_ppp::parser::{parse_markdown, MarkdownParserState};
let state = MarkdownParserState::new();
let input = "# Hello World\n\nThis is **bold** text.";
match parse_markdown(state, input) {
Ok(document) => {
println!("Parsed {} blocks", document.blocks.len());
}
Err(err) => {
eprintln!("Parse error: {:?}", err);
}
}§Configuration
The parser behavior can be extensively customized using configuration:
use markdown_ppp::parser::{MarkdownParserState, config::*};
let config = MarkdownParserConfig::default()
.with_block_thematic_break_behavior(ElementBehavior::Skip)
.with_inline_emphasis_behavior(ElementBehavior::Parse);
let state = MarkdownParserState::with_config(config);Modules§
- config
- Configuration options for Markdown parsing behavior.
Structs§
- Markdown
Parser State - Parser state containing configuration and shared context
Functions§
- parse_
markdown - Parse a Markdown string into an Abstract Syntax Tree (AST)