...

Package d2lib

import "oss.terrastruct.com/d2/d2lib"
Overview
Index

Overview ▾

func Compile

func Compile(ctx context.Context, input string, compileOpts *CompileOptions, renderOpts *d2svg.RenderOpts) (*d2target.Diagram, *d2graph.Graph, error)

func Parse

func Parse(ctx context.Context, input string, compileOpts *CompileOptions) (*d2ast.Map, error)

type CompileOptions

type CompileOptions struct {
    UTF16Pos       bool
    FS             fs.FS
    MeasuredTexts  []*d2target.MText
    Ruler          *textmeasure.Ruler
    RouterResolver func(engine string) (d2graph.RouteEdges, error)
    LayoutResolver func(engine string) (d2graph.LayoutGraph, error)

    Layout *string

    // FontFamily controls the font family used for all texts that are not the following:
    // - code
    // - latex
    // - pre-measured (web setting)
    // TODO maybe some will want to configure code font too, but that's much lower priority
    FontFamily *d2fonts.FontFamily

    InputPath string
}