Skip to main content

Module html

Module html 

Source
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:

ExtensionConfig FlagDescription
Section wrappingenable_sectionsWraps content in <section> tags with <hr> as dividers
Mermaid diagramsenable_mermaidRenders ```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 HtmlConfig for extension configuration
  • Added section_started field for section tracking
  • Added container_depth field so section boundaries are only emitted at top level (a </section> inside a blockquote or list mis-nests)
  • Added codeblock_state field for mermaid closing tag handling
  • Link and image destinations with a script-capable scheme (javascript:, vbscript:, non-image data:) are replaced with an inert value
  • Images are emitted with loading="lazy" decoding="async"
  • Removed ContainerBlock handling (not used in MBR)

Output is pinned by a golden corpus in tests/render_golden.rs.

Structs§

BlockLine
The source line one block-level element was written on, addressed by the element’s Start event’s index in the stream handed to the writer.
HtmlConfig
Configuration for MBR-specific HTML extensions.

Functions§

push_html
Iterate over an Iterator of Events, generate HTML for each Event, and push it to a String.
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 Iterator of Events, generate HTML for each Event, and write it into Unicode-accepting buffer or stream.
write_html_io
Iterate over an Iterator of Events, generate HTML for each Event, and write it out to an I/O stream.