MermaidDocument Class

A diagram read from the Mermaid text format: its content, and the warnings about the valid parts that are not supported. The front matter (title, config), the %%{init: ...}%% directives, the %% comments and the accessibility statements are read for every type of diagram.

public sealed class MermaidDocument

Properties

NameDescription
ContentGets what the text describes: a Diagram of Meziantou.Framework.Diagrams, such as a FlowchartDiagram, or a MermaidChart drawn with Meziantou.Framework.Charts, such as a PieChart. Cast it to its type to read or change it.
DiagramTypeGets the keyword that declares the type of the diagram, such as flowchart or classDiagram.
SupportedDiagramTypesGets the keywords of the types of diagrams that can be read.
WarningsGets the parts of the text that are valid Mermaid but are not supported, and are ignored.

Gets what the text describes: a Diagram of Meziantou.Framework.Diagrams, such as a FlowchartDiagram, or a MermaidChart drawn with Meziantou.Framework.Charts, such as a PieChart. Cast it to its type to read or change it.

public ISceneSource Content { get; }

Property value

ISceneSource

Gets the keyword that declares the type of the diagram, such as flowchart or classDiagram.

public string DiagramType { get; }

Property value

string

SupportedDiagramTypes

MermaidDocument.cs

Gets the keywords of the types of diagrams that can be read.

public static IReadOnlyList<string> SupportedDiagramTypes { get; }

Property value

IReadOnlyList<string>

Gets the parts of the text that are valid Mermaid but are not supported, and are ignored.

public IReadOnlyList<MermaidWarning> Warnings { get; }

Methods

NameDescription
Parse(string, MermaidParseOptions?)Reads a Mermaid text.
TryParse(string?, MermaidDocument?)Tries to read a Mermaid text.
TryParse(string?, MermaidParseOptions?, MermaidDocument?, MermaidParseError)Tries to read a Mermaid text.

Parse(string, MermaidParseOptions?)

MermaidDocument.cs

Reads a Mermaid text.

public static MermaidDocument Parse(string text, MermaidParseOptions? options = null)

Parameters

text string
The text.
options MermaidParseOptions?
The options, or null for MermaidParseOptions.Default.

Returns

MermaidDocument The document.

Exceptions

MermaidParseException
The text is not valid, or its type of diagram is not supported.

TryParse overloads

TryParse(string?, MermaidDocument?)

MermaidDocument.cs

Tries to read a Mermaid text.

public static bool TryParse(string? text, out MermaidDocument? document)
Parameters
text string?
The text.
document MermaidDocument?
The document, when the method returns true.
Returns

bool true when the text is valid.

TryParse(string?, MermaidParseOptions?, MermaidDocument?, MermaidParseError)

MermaidDocument.cs

Tries to read a Mermaid text.

public static bool TryParse(string? text, MermaidParseOptions? options, out MermaidDocument? document, out MermaidParseError error)
Parameters
text string?
The text.
options MermaidParseOptions?
The options, or null for MermaidParseOptions.Default.
document MermaidDocument?
The document, when the method returns true.
error MermaidParseError
The error, when the method returns false.
Returns

bool true when the text is valid.