Mermaid-compatible diagram parsing and native rendering implemented with Kotlin Multiplatform. The project does not use a WebView or JavaScript at runtime.
This is an independent, non-official implementation. Compatibility is declared per diagram family and syntax feature; unsupported syntax fails with typed diagnostics rather than silently rendering a different diagram.
mermaid-core: parser, typed AST, and diagnostics.mermaid-layout-api: toolkit-neutral scene graph, draw commands, and layout SPI.mermaid-layout-simple: deterministic Apache-2.0 starter layout.mermaid-render-svg: common SVG serializer.mermaid-kuikly: reserved module for the future Kuikly Canvas/Text adapter; the native renderer is not implemented yet.mermaid-testkit: compatibility fixtures and geometry goldens.
All artifacts share one version and are published under build.raft.mermaid.
Read the optimized documentation site at https://botiverse.github.io/mermaid-native/.
ELK support is deliberately outside the Apache-2.0 core; any future layout-elk
artifact must carry its own EPL-2.0 obligations.
Mermaid Native is licensed under the Apache License, Version 2.0. See
LICENSE and NOTICE. Compatibility fixtures and other
third-party material retain their upstream licenses and attribution as listed
in NOTICE; the project license does not relicense those materials.
The first supported syntax slices are:
sequenceDiagramwith oneA->>Bmessage;flowchartwith oneA-->Bedge.
Parser support is covered on Android and iOS. Layout, SVG, and native host support remain separate compatibility entries and are not implied by parser support.
val result = MermaidParser.parse("flowchart LR; A[Start] --> B[Finish]")
when (result) {
is MermaidParseResult.Success -> {
// Pass the typed diagram to a layout/render module.
}
is MermaidParseResult.Failure -> result.diagnostics.forEach(::println)
}The parser is deliberately fail-closed: syntax outside the declared support matrix returns a typed diagnostic instead of silently changing diagram type or dropping statements. See compatibility, architecture, and testing.
The samples directory contains flowchart and sequence sources
adapted from the pinned beautiful-mermaid corpus and same-named SVG goldens
generated by the common deterministic layout/renderer. The same inputs have
normalized AST expectations in mermaid-testkit, so examples are executed by
the multiplatform test suite instead of drifting as documentation-only text.
This is an independent, non-official Mermaid-compatible implementation. New syntax needs a support-matrix entry, parser tests, a negative/unsupported case, and a fixture or differential vector before it is considered complete. See CONTRIBUTING.md.