Skip to main content

generate_html_with_options_wasm

Function generate_html_with_options_wasm 

Source
pub fn generate_html_with_options_wasm(
    markdown: &str,
    options_json: &str,
) -> Result<String, JsValue>
Expand description

Render Markdown with a JSON-encoded subset of HtmlConfig.

The JSON object accepts these keys (all optional, all booleans or strings, defaults match HtmlConfig::default):

  • add_aria_attributes (bool) — inject ARIA labels and roles.
  • generate_toc (bool) — replace the [[TOC]] placeholder with a generated table of contents.
  • generate_structured_data (bool) — emit a <script type="application/ld+json"> JSON-LD block.
  • generate_full_document (bool) — wrap output in <!DOCTYPE html>.
  • enable_math (bool) — render $..$ and $$..$$ to MathML (requires the math feature, on by default).
  • enable_diagrams (bool) — rewrite mermaid fenced blocks for client-side mermaid.js.
  • language (string) — BCP 47 language code for the <html> lang attribute when full-document mode is on.
  • minify_output (bool) — minify the final HTML.

File-I/O fields (encoding, max_buffer_size) are accepted for shape compatibility but ignored: WASM has no host filesystem.

§Errors

Returns a JsValue carrying:

  • "invalid options JSON: …" if options_json does not parse as a JSON object.
  • The crate::error::HtmlError display string when the underlying render fails.