@mmd-toolkit/ast
v0.4.1
Published
TypeScript types of the abstract syntax tree of @mmd-toolkit/parser
Readme
@mmd-toolkit/ast
Japanese version: README.ja.md
The TypeScript types of the syntax tree of a Mermaid
diagram that @mmd-toolkit/parser returns: a type for every node,
such as Root, FlowchartVertex, and Identifier, and DiagramType, the
union of the diagram type ids. The names and fields are those of the
specification's ast.md.
The package holds types only and no code that runs.
It is a third-party project, not affiliated with mermaid-js.
Documentation: Parser API.
Installation
Install it next to the parser, at the version of the parser or a later compatible one:
npm install @mmd-toolkit/parser
npm install --save-dev @mmd-toolkit/astThe parser, prettier-plugin-mmd, and @mmd-toolkit/eslint-plugin declare this
package as an optional peer dependency, so that their users download it only
when they use the types. The parser asks for ^ of its own version; the two
plugins accept any version.
Usage
Import the types from this package; the parser does not export them:
import { parse } from "@mmd-toolkit/parser"
import type { Root } from "@mmd-toolkit/ast"
const root: Root = parse("flowchart LR\nA --> B\n")