Expand description
Markdown pretty-printer for formatting AST back to Markdown.
Render AST to Markdown using render_markdown.
Markdown pretty-printer for formatting AST back to Markdown
This module provides functionality to render a Markdown Abstract Syntax Tree (AST) back to formatted Markdown text. The printer supports configurable formatting options and produces clean, readable Markdown output.
§Features
- Full AST support: All CommonMark + GFM elements are supported
- Configurable formatting: Control line width, indentation, and spacing
- Pretty-printing: Intelligent line wrapping and formatting
- Round-trip capability: Parse → Render → Parse produces equivalent AST
- GitHub extensions: Tables, task lists, alerts, footnotes, strikethrough
§Basic Usage
use markdown_ppp::ast::*;
use markdown_ppp::printer::{render_markdown, 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("formatted".to_string())]),
Inline::Text(" text.".to_string()),
]),
],
};
let config = Config::default();
let markdown = render_markdown(&doc, config);
println!("{}", markdown);§Configuration
Customize the output format using configuration:
use markdown_ppp::printer::{render_markdown, config::Config};
use markdown_ppp::ast::{Document, Block, Inline};
let config = Config::default().with_width(120);
let doc = Document { blocks: vec![Block::Paragraph(vec![Inline::Text("Hello".to_string())])] };
let markdown = render_markdown(&doc, config);Modules§
- config
- Configuration options for Markdown pretty-printing.
Functions§
- render_
markdown - Render a Markdown AST back to formatted Markdown text