Expand description
HTML renderer for converting Markdown AST to HTML. HTML renderer for converting Markdown AST to HTML
This module provides functionality to render a Markdown Abstract Syntax Tree (AST) into clean, semantic HTML. The renderer supports all CommonMark + GitHub Flavored Markdown features and produces standards-compliant HTML output.
§Features
- Full AST coverage: All CommonMark + GFM elements are supported
- Semantic HTML: Produces clean, accessible HTML with proper structure
- GitHub extensions: Tables, task lists, alerts, footnotes, strikethrough
- Link resolution: Automatic resolution of reference links and footnotes
- Configurable output: Control HTML formatting and features
- Security: Proper escaping of HTML entities and attributes
§Basic Usage
use markdown_ppp::ast::*;
use markdown_ppp::html_printer::{render_html, config::Config};
let doc = Document {
blocks: vec![
Block::Heading(Heading {
kind: HeadingKind::Atx(1),
content: vec![Inline::Text("Hello World".to_string())],
}),
Block::Paragraph(vec![
Inline::Text("This is ".to_string()),
Inline::Strong(vec![Inline::Text("bold".to_string())]),
Inline::Text(" text.".to_string()),
]),
],
};
let config = Config::default();
let html = render_html(&doc, config);
assert!(html.contains("<h1>Hello World</h1>"));
assert!(html.contains("<strong>bold</strong>"));§Configuration
Customize the HTML output using [Config]:
use markdown_ppp::html_printer::{render_html, config::Config};
use markdown_ppp::ast::Document;
let config = Config::default();
let html = render_html(&Document::default(), config);Modules§
Functions§
- render_
html - Render a Markdown AST to semantic HTML