Skip to main content

Crate rich_mermaid

Crate rich_mermaid 

Source
Expand description

Mermaid diagrams for the rich Rust port.

Mermaid renders a diagram’s source. Three kinds are drawn as text with box-drawing characters (or ASCII), with no external tools: flowcharts (graph / flowchart, flowchart) and ER diagrams (erDiagram, er) through rs-rich-diagram’s layered layout, and sequence diagrams (sequenceDiagram, sequence) on lifelines. With the optional mmdc feature, and when asked for with Backend::Mmdc, every diagram type is rendered by Mermaid’s own CLI and shown as an image through rs-rich-art. Whatever cannot be drawn is shown as its source, in a code block, under a one-line note saying why.

MermaidPlugin registers the same through the plugin API: a fence renderer for ```mermaid blocks in Markdown and a mermaid source renderer. It uses only public items of rich and rich_plugin_api.

use rich::Console;
use rich_mermaid::Mermaid;

let console = Console::builder().width(40).color_system(None).build();
let out = console.render_to_string(&Mermaid::new("graph LR\n  A --> B"));
assert!(out.contains("│ A ├─►│ B │"), "{out}");

Re-exports§

pub use flowchart::Flowchart;
pub use flowchart::ParseError;
pub use flowchart::parse;
pub use layout::Diagram;
pub use layout::draw;

Modules§

er
Parse Mermaid entity-relationship diagrams (erDiagram) and draw them as text, through rs-rich-diagram’s layered layout.
flowchart
Parse Mermaid flowcharts (graph / flowchart).
layout
Draw a Flowchart as text.
sequence
Parse Mermaid sequence diagrams (sequenceDiagram) and draw them as text.

Structs§

Mermaid
A Mermaid diagram.
MermaidFences
Renders ```mermaid fences in [rich::markdown::Markdown].
MermaidOptions
How to render diagrams.
MermaidPlugin
Registers the mermaid fence renderer and source renderer.

Enums§

Backend
Which renderer to try first.