Skip to main content

check

Function check 

Source
pub fn check(
    lang: &str,
    code: &str,
) -> Result<Vec<DiagramWarning>, MermaidError>
Expand description

Validate diagram without rendering output.

Parses the input and runs layout (for cycle detection) but skips the expensive grid rendering. Use this for validation-only workflows.

Note: This only catches structural warnings (e.g. cycles). Width-dependent warnings like LabelDropped depend on max_width which is only applied during rendering โ€” use render() if you need those.

Dispatches by lang: "d2" โ†’ D2 parser, anything else โ†’ Mermaid auto-detect.

ยงExample

use graphs_tui::check;

let warnings = check("mermaid", "flowchart LR\nA --> B\nB --> A").unwrap();
assert!(!warnings.is_empty()); // cycle detected