Skip to main content

to_html_fragment

Function to_html_fragment 

Source
pub fn to_html_fragment(blocks: &[Block]) -> String
Expand description

Render a slice of blocks as bare HTML fragments.

Unlike to_html(), this does NOT:

  • Scan for ::site/::style blocks or emit CSS variable overrides
  • Extract or render navigation blocks separately
  • Wrap content in auto-sectioning (h1/h2 boundary detection)

Each block is rendered through [render_block()] and the results are joined with newlines. The caller controls the CSS context — fragment HTML assumes surfdoc-* class names are available from a parent stylesheet.

Returns an empty string for an empty slice.