Documentation
¶
Overview ¶
Package sketch draws Mermaid diagrams as SVG. It is a Go port of pele (github.com/obsidianmd/pele), which draws them without a browser.
Index ¶
Constants ¶
const ( CodeUnsupported = types.CodeUnsupported CodeSyntax = types.CodeSyntax CodeSemantic = types.CodeSemantic CodeLimit = types.CodeLimit )
const DefaultLimit = 50000
DefaultLimit is the longest source in characters: Mermaid's default maxTextSize.
const DefaultMaxEdges = 5000
DefaultMaxEdges is the most edges a flowchart can have. Mermaid stops at 500. Pele draws 5,000 edges in tens of milliseconds, and `A & B --> C & D` multiplies: without a limit, a few kilobytes of source ask for millions of edges.
const DefaultOutputLimit = 4_000_000
DefaultOutputLimit is the longest SVG in characters. Mermaid has no limit on its output. A source within the limit can still describe a drawing of many megabytes, which would stall the page it is put into.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Diagram ¶
type Diagram struct {
Type Type
// contains filtered or unexported fields
}
Diagram is diagram text that parsed. RenderSVG draws it.
func Parse ¶
func Parse(src string, opt ParseOptions) (d *Diagram, err error)
Parse reads diagram text.
type ErrorCode ¶
type ErrorCode = types.PeleErrorCode
ErrorCode says what kind of problem an Error is.
type Layout ¶
Layout is the geometry a renderer worked out for a diagram, in SVG units: boxes, routes and label lines. It is not part of pele. sketch/text draws it with box-drawing characters.
type NamedTheme ¶
type NamedTheme struct {
// Name is the key: lower case, words joined with "-".
Name string
// Title is the name for people, such as "Rosé Pine".
Title string
// Dark says the background is dark.
Dark bool
Theme Theme
}
NamedTheme is a theme with the name a user types for it.
func Themes ¶
func Themes() []NamedTheme
Themes lists the named themes: pele's own first, then terminal themes.
type ParseOptions ¶
ParseOptions are the options read when the text is parsed.
type RenderOptions ¶
type RenderOptions = types.RenderOptions
RenderOptions are pele's render options. A nil pointer is an option left unset.
type TextMeasurer ¶
type TextMeasurer = text.TextMeasurer
TextMeasurer gives the width of text. The default is a table of Arial advances, which gives the same output as pele.
type Theme ¶
Theme sets the colours, fonts and radius of a diagram through pele's --pele-* tokens.
func ThemeNamed ¶
ThemeNamed finds a named theme. Case, spaces and "_" do not matter.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
diagrams/class
Package class parses and draws Mermaid class diagrams.
|
Package class parses and draws Mermaid class diagrams. |
|
diagrams/common
Package common holds what several diagram types share.
|
Package common holds what several diagram types share. |
|
diagrams/er
Package er parses and draws Mermaid entity relationship diagrams.
|
Package er parses and draws Mermaid entity relationship diagrams. |
|
diagrams/flowchart
Package flowchart parses and draws Mermaid flowcharts.
|
Package flowchart parses and draws Mermaid flowcharts. |
|
diagrams/gantt
Package gantt parses and draws Mermaid gantt charts.
|
Package gantt parses and draws Mermaid gantt charts. |
|
diagrams/sequence
Package sequence parses and draws Mermaid sequence diagrams.
|
Package sequence parses and draws Mermaid sequence diagrams. |
|
diagrams/state
Package state parses and draws Mermaid state diagrams.
|
Package state parses and draws Mermaid state diagrams. |
|
js
Package js holds the few JavaScript semantics the port depends on for byte identical output: Math.round, Number to string, the \s whitespace set, trim, parseFloat and Number(), and UTF-16 lengths.
|
Package js holds the few JavaScript semantics the port depends on for byte identical output: Math.round, Number to string, the \s whitespace set, trim, parseFloat and Number(), and UTF-16 lengths. |
|
layout
Package layout holds pele's own graph layouts: layered (Sugiyama style), compound (clusters on top of layered) and lanes.
|
Package layout holds pele's own graph layouts: layered (Sugiyama style), compound (clusters on top of layered) and lanes. |
|
svg
Package svg writes the SVG that every diagram type shares: text, shapes, edges, clusters and the root element.
|
Package svg writes the SVG that every diagram type shares: text, shapes, edges, clusters and the root element. |
|
text
Package text measures and lays out label text.
|
Package text measures and lays out label text. |
|
types
Package types holds what every diagram type shares: options, results, errors and the Diagram interface.
|
Package types holds what every diagram type shares: options, results, errors and the Diagram interface. |
|
util
Package util holds pele's small shared helpers: character tests, the YAML subset for front matter, and URL sanitising.
|
Package util holds pele's small shared helpers: character tests, the YAML subset for front matter, and URL sanitising. |
|
Package raster draws the SVG that tuios.dev/sketch writes into an image.
|
Package raster draws the SVG that tuios.dev/sketch writes into an image. |
|
Package text draws diagrams with box-drawing characters, for terminals that show no pictures.
|
Package text draws diagrams with box-drawing characters, for terminals that show no pictures. |