Module html_printer

Module html_printer 

Source
Expand description

HTML renderer for converting Markdown AST to HTML.

Render AST to HTML using render_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("<b>bold</b>"));

§Configuration

Customize the HTML output using configuration:

use markdown_ppp::html_printer::{render_html, config::Config};
use markdown_ppp::ast::{Document, Block, Inline};

let config = Config::default();
let doc = Document { blocks: vec![Block::Paragraph(vec![Inline::Text("Hello".to_string())])] };
let html = render_html(&doc, config);

Modules§

config
Configuration options for HTML rendering.

Functions§

render_html
Render a Markdown AST to semantic HTML