parser

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package parser provides parsing functionality for Mermaid diagrams.

Package parser provides parsing functionality for all Mermaid diagram types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(source string) (ast.Diagram, error)

Parse parses a Mermaid diagram from source and returns a Diagram. It automatically detects the diagram type and uses the appropriate parser.

Types

type C4ComponentParser

type C4ComponentParser struct{}

C4ComponentParser parses C4 Component diagrams.

func NewC4ComponentParser

func NewC4ComponentParser() *C4ComponentParser

NewC4ComponentParser creates a new C4 Component parser.

func (*C4ComponentParser) Parse

func (p *C4ComponentParser) Parse(source string) (ast.Diagram, error)

Parse parses a C4 Component diagram and returns a C4Diagram AST.

func (*C4ComponentParser) SupportedTypes

func (p *C4ComponentParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser supports.

type C4ContainerParser

type C4ContainerParser struct{}

C4ContainerParser parses C4 Container diagrams.

func NewC4ContainerParser

func NewC4ContainerParser() *C4ContainerParser

NewC4ContainerParser creates a new C4 Container parser.

func (*C4ContainerParser) Parse

func (p *C4ContainerParser) Parse(source string) (ast.Diagram, error)

Parse parses a C4 Container diagram and returns a C4Diagram AST.

func (*C4ContainerParser) SupportedTypes

func (p *C4ContainerParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser supports.

type C4ContextParser

type C4ContextParser struct{}

C4ContextParser parses C4 Context diagrams.

func NewC4ContextParser

func NewC4ContextParser() *C4ContextParser

NewC4ContextParser creates a new C4 Context parser.

func (*C4ContextParser) Parse

func (p *C4ContextParser) Parse(source string) (ast.Diagram, error)

Parse parses a C4 Context diagram and returns a C4Diagram AST.

func (*C4ContextParser) SupportedTypes

func (p *C4ContextParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser supports.

type C4DeploymentParser

type C4DeploymentParser struct{}

C4DeploymentParser parses C4 Deployment diagrams.

func NewC4DeploymentParser

func NewC4DeploymentParser() *C4DeploymentParser

NewC4DeploymentParser creates a new C4 Deployment parser.

func (*C4DeploymentParser) Parse

func (p *C4DeploymentParser) Parse(source string) (ast.Diagram, error)

Parse parses a C4 Deployment diagram and returns a C4Diagram AST.

func (*C4DeploymentParser) SupportedTypes

func (p *C4DeploymentParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser supports.

type C4DynamicParser

type C4DynamicParser struct{}

C4DynamicParser parses C4 Dynamic diagrams.

func NewC4DynamicParser

func NewC4DynamicParser() *C4DynamicParser

NewC4DynamicParser creates a new C4 Dynamic parser.

func (*C4DynamicParser) Parse

func (p *C4DynamicParser) Parse(source string) (ast.Diagram, error)

Parse parses a C4 Dynamic diagram and returns a C4Diagram AST.

func (*C4DynamicParser) SupportedTypes

func (p *C4DynamicParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser supports.

type ClassParser

type ClassParser struct{}

ClassParser parses Mermaid class diagrams.

func NewClassParser

func NewClassParser() *ClassParser

NewClassParser creates a new class diagram parser.

func (*ClassParser) Parse

func (p *ClassParser) Parse(source string) (ast.Diagram, error)

Parse parses a Mermaid class diagram from a string.

func (*ClassParser) SupportedTypes

func (p *ClassParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser handles.

type DiagramParser

type DiagramParser interface {
	// Parse parses the source and returns a Diagram AST.
	Parse(source string) (ast.Diagram, error)
	// SupportedTypes returns the diagram types this parser handles.
	SupportedTypes() []string
}

DiagramParser defines the interface all diagram parsers must implement.

type ERParser

type ERParser struct{}

ERParser handles parsing of ER diagrams.

func NewERParser

func NewERParser() *ERParser

NewERParser creates a new ER parser.

func (*ERParser) Parse

func (p *ERParser) Parse(source string) (ast.Diagram, error)

Parse parses an ER diagram source.

func (*ERParser) SupportedTypes

func (p *ERParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser supports.

type FlowchartParser

type FlowchartParser struct {
	// contains filtered or unexported fields
}

FlowchartParser parses Mermaid flowchart and graph diagrams.

func NewFlowchartParser

func NewFlowchartParser() *FlowchartParser

NewFlowchartParser creates a new flowchart parser.

func (*FlowchartParser) Parse

func (p *FlowchartParser) Parse(source string) (ast.Diagram, error)

Parse parses a Mermaid flowchart/graph diagram from a string.

func (*FlowchartParser) ParseBytes

func (p *FlowchartParser) ParseBytes(_ string, source []byte) (*ast.Flowchart, error)

ParseBytes parses a Mermaid flowchart/graph diagram from bytes.

func (*FlowchartParser) SupportedTypes

func (p *FlowchartParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser handles.

type GanttParser

type GanttParser struct{}

GanttParser handles parsing of Gantt chart diagrams.

func NewGanttParser

func NewGanttParser() *GanttParser

NewGanttParser creates a new Gantt parser.

func (*GanttParser) Parse

func (p *GanttParser) Parse(source string) (ast.Diagram, error)

Parse parses a Gantt chart diagram source.

func (*GanttParser) SupportedTypes

func (p *GanttParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser supports.

type GitGraphParser

type GitGraphParser struct{}

GitGraphParser handles parsing of git graph diagrams.

func NewGitGraphParser

func NewGitGraphParser() *GitGraphParser

NewGitGraphParser creates a new git graph parser.

func (*GitGraphParser) Parse

func (p *GitGraphParser) Parse(source string) (ast.Diagram, error)

Parse parses a git graph diagram source.

func (*GitGraphParser) SupportedTypes

func (p *GitGraphParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser supports.

type JourneyParser

type JourneyParser struct{}

JourneyParser handles parsing of user journey diagrams.

func NewJourneyParser

func NewJourneyParser() *JourneyParser

NewJourneyParser creates a new journey parser.

func (*JourneyParser) Parse

func (p *JourneyParser) Parse(source string) (ast.Diagram, error)

Parse parses a user journey diagram source.

func (*JourneyParser) SupportedTypes

func (p *JourneyParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser supports.

type MindmapParser

type MindmapParser struct{}

MindmapParser handles parsing of mindmap diagrams.

func NewMindmapParser

func NewMindmapParser() *MindmapParser

NewMindmapParser creates a new mindmap parser.

func (*MindmapParser) Parse

func (p *MindmapParser) Parse(source string) (ast.Diagram, error)

Parse parses a mindmap diagram source.

func (*MindmapParser) SupportedTypes

func (p *MindmapParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser supports.

type PieParser

type PieParser struct{}

PieParser handles parsing of pie chart diagrams.

func NewPieParser

func NewPieParser() *PieParser

NewPieParser creates a new pie parser.

func (*PieParser) Parse

func (p *PieParser) Parse(source string) (ast.Diagram, error)

Parse parses a pie chart diagram source.

func (*PieParser) SupportedTypes

func (p *PieParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser supports.

type QuadrantParser

type QuadrantParser struct{}

QuadrantParser handles parsing of quadrant chart diagrams.

func NewQuadrantParser

func NewQuadrantParser() *QuadrantParser

NewQuadrantParser creates a new quadrant parser.

func (*QuadrantParser) Parse

func (p *QuadrantParser) Parse(source string) (ast.Diagram, error)

Parse parses a quadrant chart diagram source.

func (*QuadrantParser) SupportedTypes

func (p *QuadrantParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser supports.

type SankeyParser

type SankeyParser struct{}

SankeyParser handles parsing of Sankey diagrams.

func NewSankeyParser

func NewSankeyParser() *SankeyParser

NewSankeyParser creates a new Sankey parser.

func (*SankeyParser) Parse

func (p *SankeyParser) Parse(source string) (ast.Diagram, error)

Parse parses a Sankey diagram source.

func (*SankeyParser) SupportedTypes

func (p *SankeyParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser supports.

type SequenceParser

type SequenceParser struct{}

SequenceParser parses Mermaid sequence diagrams.

func NewSequenceParser

func NewSequenceParser() *SequenceParser

NewSequenceParser creates a new sequence diagram parser.

func (*SequenceParser) Parse

func (p *SequenceParser) Parse(source string) (ast.Diagram, error)

Parse parses a Mermaid sequence diagram from a string.

func (*SequenceParser) SupportedTypes

func (p *SequenceParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser handles.

type StateParser

type StateParser struct{}

StateParser parses Mermaid state diagrams.

func NewStateParser

func NewStateParser() *StateParser

NewStateParser creates a new state diagram parser.

func (*StateParser) Parse

func (p *StateParser) Parse(source string) (ast.Diagram, error)

Parse parses a Mermaid state diagram from a string.

func (*StateParser) SupportedTypes

func (p *StateParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser handles.

type TimelineParser

type TimelineParser struct{}

TimelineParser handles parsing of timeline diagrams.

func NewTimelineParser

func NewTimelineParser() *TimelineParser

NewTimelineParser creates a new timeline parser.

func (*TimelineParser) Parse

func (p *TimelineParser) Parse(source string) (ast.Diagram, error)

Parse parses a timeline diagram source.

func (*TimelineParser) SupportedTypes

func (p *TimelineParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser supports.

type XYChartParser

type XYChartParser struct{}

XYChartParser handles parsing of XY chart diagrams.

func NewXYChartParser

func NewXYChartParser() *XYChartParser

NewXYChartParser creates a new XY chart parser.

func (*XYChartParser) Parse

func (p *XYChartParser) Parse(source string) (ast.Diagram, error)

Parse parses an XY chart diagram source.

func (*XYChartParser) SupportedTypes

func (p *XYChartParser) SupportedTypes() []string

SupportedTypes returns the diagram types this parser supports.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL