Compatibility

Supported diagram types, and how limu differs from Pele and Mermaid.

View Markdown

limu-rs and limu parse Mermaid text the way Pele 1.13.0 does and produce the same layout, number for number. Where limu differs from Mermaid, it’s almost always because Pele does.

Diagram types

limu supports every diagram type Pele draws, which covers every type built into Mermaid 12.1.0. Examples shows each one.

TypeKeywords
Flowchartgraph, flowchart
Swimlaneswimlane-beta
SequencesequenceDiagram
ClassclassDiagram
StatestateDiagram, stateDiagram-v2
Entity relationshiperDiagram
Ganttgantt
Git graphgitGraph
Piepie
Mindmapmindmap
Kanbankanban
Timelinetimeline
User journeyjourney
Quadrant chartquadrantChart
XY chartxychart, xychart-beta
RequirementrequirementDiagram
Sankeysankey, sankey-beta
Architecturearchitecture-beta
C4C4Context, C4Container, C4Component, C4Dynamic, C4Deployment
Blockblock, block-beta
Agentflowagentflow-beta
Railroadrailroad-beta, railroad-ebnf-beta, railroad-abnf-beta, railroad-peg-beta
Tree viewtreeView-beta
Cynefincynefin-beta
Wardley mapwardley-beta
Event modelingeventmodeling
Use caseusecase-beta
Vennvenn-beta
Ishikawaishikawa, ishikawa-beta
Packetpacket, packet-beta
Radarradar-beta
Treemaptreemap, treemap-beta
Infoinfo

ZenUML and other external Mermaid plugins aren’t supported. Use limu::supports limu.Supports to check whether limu supports a text’s type.

Every type supports front matter, %%{init}%% directives, comments, and the accessibility title and description (accTitle, accDescr). Which configuration settings each type honors is the same as in Pele.

Differences from Pele

Pele’s API in limu

Pele renders SVG in a browser, while limu lays out a scene for a backend to draw. Pele’s options are therefore spread across limu’s stages.

Pelelimu-rs
render(source, options)limu::layout, then a backend such as svg::render
parse(source, options)limu::parse
supportslimu::supports
type, mermaidTypeDiagram::diagram_type(), Diagram::mermaid_type()
PeleError and its codeslimu::Error and ErrorCode
limit, maxEdges, configlimu::ParseOptions
measurer, fontSize, maxWidth, autoDirection, directionBreakpoint, padding, monospace, nowlimu::layout::Options, where keep_direction is the opposite of autoDirection
links, images, linkSchemes, imageSchemeslimu::layout::Options and svg::Options
fontFamily, fontFamilyMonosvg::Options’s font_family and mono_family
iconslimu::layout::Options::icons, plus svg::Options::icon_markup or a native backend’s icons
--pele-* variables, pele-* classes--limu-* variables, limu-* classes
Pelelimu
render(source, options)limu.Layout, then a backend such as svg.Render
parse(source, options)limu.Parse
detectType, supportsdiagram.DetectType, limu.Supports
type, mermaidTypeDiagram.Type(), Diagram.MermaidType()
PeleError and its codesdiagram.Error and its codes
limit, maxEdges, configdiagram.Options
measurer, fontSize, maxWidth, autoDirection, directionBreakpoint, padding, monospace, nowlayout.Options, where KeepDirection is the opposite of autoDirection
links, images, linkSchemes, imageSchemeslayout.Options and the svg package’s Options
fontFamily, fontFamilyMonoThe svg package’s FontFamily and MonoFamily
iconslayout.Options.Icons, plus the svg package’s IconMarkup or limumygo’s DrawIcon
--pele-* variables, pele-* classes--limu-* variables, limu-* classes

Features that only make sense in a browser aren’t ported. mount, its zoom and refresh are left to the app, which can do the same with the scene, for example through the scale of a native backend’s options. The SVG options responsive, idPrefix, linkRel, outputLimit and sanitize aren’t ported either. Neither are the entry points that load diagram types on demand. A Rust program turns off the features of the types it doesn’t read, and a Go program only links what it imports.

Pele’s math option isn’t ported. With it, Pele typesets $$…$$ in a label through a function the app gives. Without it, Pele keeps the label as text, and limu always does.

Drawing

limu draws a few things differently from Pele.

An info diagram shows limu’s name and version instead of Pele’s.

Pele passes the author’s font-family, letter-spacing, word-spacing and text-decoration on to the text, and in treemaps and venn diagrams it also applies a weight or size it didn’t measure the text with. limu reads only the font’s weight, style and size, and only where layout measures text with them, because text drawn differently from how it was measured won’t fit the space layout gave it.

Pele writes a sankey label and its value as one piece of text with the value in another color. limu makes them two items and places them by the width of the whole. With a measurer that kerns, the gap between them can differ slightly from Pele’s.

A link whose host name isn’t ASCII is converted to Punycode without the full UTS #46 mapping, so a few such host names come out differently from Node’s.

The native backends draw the same picture as the SVG backend, apart from the few differences each one’s page lists, such as MyGo’s.

limu-rs and limu produce the same layout on every platform, and their tests compare against Pele on both amd64 and arm64.

Text

In a browser, Pele measures text with the fonts it draws in. Without fonts, it uses a table of Arial’s character widths. limu measures with the measurer you give it. The default measurer, limu::layout::Arial text.Arial, is the same table, so with it, limu’s layout matches Pele’s to the last bit. Chinese, Japanese and Korean text wraps as it does in Pele. See Measuring text.

Differences from Mermaid

Layout and appearance

limu lays out diagrams the way Pele does, which isn’t how Mermaid does it. Node positions, spacing and edge paths all differ. Where Mermaid hands a diagram to an outside library, Pele often uses a layout of its own. Pele puts architecture diagrams on a grid where Mermaid uses a force-directed solver, and C4 and block diagrams have their own placement and routing.

Colors come from limu’s themes. Mermaid’s themes don’t apply, and of its themeVariables limu reads only the palettes that set a diagram’s series colors, as Pele does.

Sizing

Diagrams that can get narrower do so to fit the layout’s maximum width, max_width MaxWidth. A wide flowchart, for example, may run down instead of across. Set keep_direction KeepDirection to prevent that.

Subgraphs

As in Mermaid, a flowchart subgraph that an edge crosses, from a node inside it to one outside, takes its parent’s direction. Its own direction applies only when no edge crosses its border.

Limits

limu limits the length of a diagram’s text and the number of edges in flowcharts and agent flows. See Limits.

Labels

Labels support line breaks, bold and italic, written with <br>, <b> and <i> or as Markdown strings. They also read <code>, <sub>, <sup> and <u>, and their kin such as <strong>, <em>, <kbd> and <ins>. Other HTML tags are dropped and their text kept. Text shaped like a tag that HTML doesn’t have, such as the type in List<T>, is shown as written.

Interaction

A click that opens a link sets the item’s link, and your app decides whether to follow it. A click that calls a function is ignored.

Icons

Your app supplies icons such as fa:fa-car. See SVG and the page of each native backend, such as MyGo. Architecture and tree view diagrams also have built-in symbols.

Reporting differences

If limu or limu-rs parses or lays out a diagram differently from Pele, that’s a bug in the port. Open the diagram in limu’s playground and in Pele’s, then report the difference to limu or limu-rs. If Pele draws it the same way and both differ from Mermaid, report it to Pele instead.