merman-render
merman-render is the low-level layout and SVG crate behind merman. It consumes merman-core parse results and produces layout JSON or Mermaid-like SVG.
Most applications should start with the merman crate and merman::render::HeadlessRenderer. Use merman-render directly when you need lower-level control over layout, text measurement, SVG options, or SVG postprocessing.
What It Provides
- Headless layout for parsed Mermaid diagrams.
- Mermaid-parity SVG emission.
LayoutOptions::headless_svg_defaults()for editor/export use cases.- Text measurement hooks through
TextMeasurer. - Math rendering hooks through
MathRenderer. SvgPipelinepresets and postprocessors for readable or rasterizer-friendly SVG.
Direct Rendering Example
use ;
use ;
use ;
SVG Output Pipelines
The default SVG renderer aims for Mermaid DOM parity. Host applications can opt into an output pipeline after rendering:
SvgPipeline::parity()leaves the SVG unchanged.SvgPipeline::readable()keeps fallback text for<foreignObject>labels.SvgPipeline::resvg_safe()prepares SVG for commonusvg/resvgrasterization paths.ScopedCssPostprocessor,CssOverridePostprocessor, and customSvgPostprocessorimplementations let applications inject host-specific styling without forking the renderer.
See docs/rendering/SVG_OUTPUT_PIPELINE.md for the higher-level integration guide.
Relationship To merman
merman re-exports the common render APIs behind its render feature and adds HeadlessRenderer, SVG id sanitization helpers, and optional raster helpers. Direct merman-render users get the same layout/SVG engine with less convenience wrapping and more explicit control over each phase.