Socket
Socket
Sign inDemoInstall

@mermaid-js/parser

Package Overview
Dependencies
15
Maintainers
6
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @mermaid-js/parser

MermaidJS parser


Version published
Weekly downloads
88
increased by95.56%
Maintainers
6
Created
Weekly downloads
 

Readme

Source

Mermaid Parser

Mermaid parser package

NPM

How the package works

The package exports a parse function that has two parameters:

declare function parse<T extends DiagramAST>(
  diagramType: keyof typeof initializers,
  text: string
): T;

How does a Langium-based parser work?

sequenceDiagram
actor Package
participant Module
participant TokenBuilder
participant Lexer
participant Parser
participant ValueConverter


Package ->> Module: Create services
Module ->> TokenBuilder: Override or/and<br>reorder rules
TokenBuilder ->> Lexer: Read the string and transform<br>it into a token stream
Lexer ->> Parser: Parse token<br>stream into AST
Parser ->> ValueConverter: Clean/modify tokenized<br>rules returned value
ValueConverter -->> Package: Return AST
  • When to override TokenBuilder?

    • To override keyword rules.
    • To override terminal rules that need a custom function.
    • To manually reorder the list of rules.
  • When to override Lexer?

    • To modify input before tokenizing.
    • To insert/modify tokens that cannot or have not been parsed.
  • When to override LangiumParser?

    • To insert or modify attributes that can't be parsed.
  • When to override ValueConverter?

    • To modify the returned value from the parser.

Keywords

FAQs

Last updated on 26 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc