Expand description
§MBR HTML Renderer
Modified from pulldown-cmark’s html.rs to support MBR-specific features.
§MBR Extensions
All extensions are controlled via HtmlConfig and can be enabled/disabled:
| Extension | Config Flag | Description |
|---|---|---|
| Section wrapping | enable_sections | Wraps content in <section> tags with <hr> as dividers |
| Mermaid diagrams | enable_mermaid | Renders ```mermaid blocks as <pre class="mermaid"> |
§Usage
ⓘ
// Use MBR defaults (all extensions enabled)
html::push_html_mbr(&mut output, events);
// Or configure explicitly
let config = HtmlConfig { enable_sections: true, enable_mermaid: false };
html::push_html_with_config(&mut output, events, config);§Upstream Tracking
Based on: https://github.com/pulldown-cmark/pulldown-cmark/blob/master/pulldown-cmark/src/html.rs
Key differences from upstream:
- Added
HtmlConfigfor extension configuration - Added
section_startedfield for section tracking - Added
container_depthfield so section boundaries are only emitted at top level (a</section>inside a blockquote or list mis-nests) - Added
codeblock_statefield for mermaid closing tag handling - Link and image destinations with a script-capable scheme (
javascript:,vbscript:, non-imagedata:) are replaced with an inert value - Images are emitted with
loading="lazy" decoding="async" - Removed
ContainerBlockhandling (not used in MBR)
Output is pinned by a golden corpus in tests/render_golden.rs.
Structs§
- Block
Line - The source line one block-level element was written on, addressed by the
element’s
Startevent’s index in the stream handed to the writer. - Html
Config - Configuration for MBR-specific HTML extensions.
Functions§
- push_
html - Iterate over an
IteratorofEvents, generate HTML for eachEvent, and push it to aString. - push_
html_ mbr - Push HTML with MBR extensions enabled (sections and mermaid support).
- push_
html_ mbr_ with_ attrs - Push HTML with MBR extensions and section attributes.
- push_
html_ with_ config - Push HTML with explicit configuration.
- write_
html_ fmt - Iterate over an
IteratorofEvents, generate HTML for eachEvent, and write it into Unicode-accepting buffer or stream. - write_
html_ io - Iterate over an
IteratorofEvents, generate HTML for eachEvent, and write it out to an I/O stream.