1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//! 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
//!
//! ```rust
//! 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:
//!
//! ```rust
//! 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);
//! ```
/// Configuration options for HTML rendering.
use crate*;
use ;
use ;
/// Internal rendering state for HTML generation
///
/// This structure holds the shared state needed during HTML rendering,
/// including configuration, footnote indexing, and link definition resolution.
/// It's used internally by the rendering process and is not part of the public API.
pub
/// Render a Markdown AST to semantic HTML
///
/// This function takes a parsed Markdown document (AST) and converts it to
/// clean, standards-compliant HTML. The output includes proper semantic
/// markup, accessibility features, and support for all CommonMark + GFM
/// elements.
///
/// # Arguments
///
/// * `ast` - The Markdown document AST to render
/// * `config` - Configuration options controlling the HTML output
///
/// # Returns
///
/// A `String` containing the generated HTML
///
/// # Examples
///
/// Basic HTML rendering:
/// ```rust
/// 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("Title".to_string())],
/// }),
/// Block::Paragraph(vec![
/// Inline::Text("Text with ".to_string()),
/// Inline::Strong(vec![Inline::Text("emphasis".to_string())]),
/// ]),
/// ],
/// };
///
/// let config = Config::default();
/// let html = render_html(&doc, config);
///
/// assert!(html.contains("<h1>Title</h1>"));
/// assert!(html.contains("emphasis"));
/// ```
///
/// # HTML Features
///
/// The renderer produces:
/// - Semantic HTML5 elements (`<article>`, `<section>`, `<aside>`, etc.)
/// - Proper heading hierarchy (`<h1>` through `<h6>`)
/// - Accessible tables with `<thead>`, `<tbody>`, and proper scoping
/// - Code syntax highlighting preparation with language classes
/// - Task list checkboxes with proper `disabled` attributes
/// - Footnote links with proper `aria-describedby` attributes
/// - GitHub Alert styling with appropriate CSS classes
///
/// # Security
///
/// All user content is properly escaped to prevent XSS attacks.
/// HTML content in the AST is preserved as-is (assumed to be trusted).