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, throughrs-rich-diagram’s layered layout. - flowchart
- Parse Mermaid flowcharts (
graph/flowchart). - layout
- Draw a
Flowchartas text. - sequence
- Parse Mermaid sequence diagrams (
sequenceDiagram) and draw them as text.
Structs§
- Mermaid
- A Mermaid diagram.
- Mermaid
Fences - Renders
```mermaidfences in [rich::markdown::Markdown]. - Mermaid
Options - How to render diagrams.
- Mermaid
Plugin - Registers the
mermaidfence renderer and source renderer.
Enums§
- Backend
- Which renderer to try first.