tools capa

tools-mermaid-render

Render mermaid diagrams from a Markdown file (or a lone .mmd) to standalone SVGs for reuse in articles. Extracts each ```mermaid block (pure, tested) and drives a render engine (mmdc) with a strict argument vector — no shell. Engine is used only as an offline DOM->SVG renderer of our own HTML, never to control a live site (that stays the bridge's job).

Render mermaid diagrams from a Markdown file (or a lone .mmd) to standalone SVGs for reuse in articles. Extracts each ```mermaid block (pure, tested) and drives a render engine (mmdc) with a strict argument vector — no shell. Engine is used only as an offline DOM->SVG renderer of our own HTML, never to control a live site (that stays the bridge's job).

Tiertools
Roleunclassified (baselined)
Pathcrates/tools/mermaid-render
Edition2021
Targetstools-mermaid-render, tools_mermaid_render, render_live
Public items12 across 0 modules
Tests13

What it is for

tools-mermaid-render — extract mermaid diagrams from Markdown and name their output SVGs. This library is the PURE half: block extraction, slugging, output naming. The subprocess render lives in main.rs.

Deliberate scope limits (operator, 2026-08-08):

PNG/PDF, so it cannot be talked into a different output.

(input file, output dir) and SVG files out. It takes no URL, no shell, no pass-through flags, so it cannot be repurposed to control a browser. The render engine (mmdc/puppeteer) is used ONLY as an offline DOM→SVG renderer of our own generated HTML; live-site control stays the bridge's job. Invoke it from the /diagram skill or by hand, never as a free tool a model reaches for.

Capabilities

crate root

tools-mermaid-render — extract mermaid diagrams from Markdown and name their

Item
pub const MAX_INPUT_BYTES: u64
pub const MAX_SVG_BYTES: usize
pub const RENDER_TIMEOUT: std::time::Duration
pub const RENDERER_VERSION: & str
fn puppeteer_config(dir : & std::path::Path) -> anyhow::Result <Option <std::path::PathBuf>>
fn render_to_svg(source : & str, work_dir : & std::path::Path) -> anyhow::Result <String>
fn slugify(s : & str) -> String
fn output_name(stem : & str, index : usize, heading : Option <& str>) -> String

Block

tools-mermaid-render — extract mermaid diagrams from Markdown and name their

Item
pub const MAX_BLOCK_BYTES: usize
pub const MAX_BLOCKS: usize
pub struct Block
fn extract_blocks(md : & str) -> Vec <Block>

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

No public modules: the crate root is its whole surface.

Public surface

`crate root`

ItemWhat it is
pub const MAX_INPUT_BYTES: u64Cap on the Markdown input we will read (bytes)
pub const MAX_BLOCK_BYTES: usizeCap on one block's mermaid source (bytes)
pub const MAX_SVG_BYTES: usizeCap on an SVG accepted back from the renderer (bytes)
pub const RENDER_TIMEOUT: std::time::DurationWall-clock cap for one block
pub const RENDERER_VERSION: & strThe renderer's identity, stored beside each SVG so a mermaid upgrade that changes output is visible as a version difference rather than a silent redraw.
fn puppeteer_config(dir : & std::path::Path) -> anyhow::Result <Option <std::path::PathBuf>>Resolve a Puppeteer config so mmdc reuses the system Chrome instead of downloading its own
fn render_to_svg(source : & str, work_dir : & std::path::Path) -> anyhow::Result <String>Render one mermaid source to SVG text, using work_dir for the transient source and output files
pub const MAX_BLOCKS: usizeCap on diagrams per file
pub struct BlockOne extracted diagram: the nearest preceding heading (for naming) and the mermaid source between the fences.
fn extract_blocks(md : & str) -> Vec <Block>Extract every `mermaid fenced block from Markdown, in document order
fn slugify(s : & str) -> StringLowercase kebab slug: alphanumerics kept, every run of other chars becomes a single -, trimmed
fn output_name(stem : & str, index : usize, heading : Option <& str>) -> StringOutput filename for block index (0-based) of a file whose stem is stem

No pub use re-exports: every item above is declared in this crate.

Boundary

Depends on no other workspace tier.

Shares tier tools with 84 other crates: tools-advisory-reach, tools-archive-guard, tools-artifact-scaffold, tools-ask-ai-core, tools-ask-ais, tools-ask-gemini, tools-book, tools-book-report, … (84 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)tools
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/tools/mermaid-render
Vocabulary in force (lexicon)current

Dependencies

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
anyhow^1noalways

Development. None.

Build. None.

Depended on by. 1 workspace crate.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_tools_corpus["tools-corpus"] -->|uses| SELF
  SELF["tools-mermaid-render"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
bintools-mermaid-render`src/main.rs`
libtools_mermaid_render`src/lib.rs`
testrender_live`tests/render_live.rs`

Error model

No public error type was detected: no public item declares a type named *Error, and no public signature returns one.

Operational characteristics

PropertyEvidence
async public surfacenone detected
async runtimenone detected
database accessnone detected
network I/Onone detected
unsafe codenone detected
environment variablesyes

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

VariableRead in
MERMAID_MMDCsrc/lib.rs
MERMAID_PUPPETEER_CONFIGsrc/lib.rs

1 workspace crate depends on this one: tools-corpus.

Verification

KindCount
Unit tests9
Integration tests4
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root1205

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc1212
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 12
    "No rustdoc detected" : 0

Metrics

MetricValue
Rust source files2
Source lines622
Code lines468
Public API items12
Public modules0
Tests13
Examples0
Cargo features0
Direct runtime dependencies1
Workspace reverse dependencies1
pie showData
    title Public API by kind
    "constant" : 6
    "function" : 5
    "struct" : 1
pie showData
    title Rust source composition
    "Code" : 468
    "Blank or comment" : 154

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

Todas las tools · Manual