d2svg

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MPL-2.0 Imports: 32 Imported by: 14 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

d2svg implements an SVG renderer for d2 diagrams. The input is d2exporter's output

Index

Constants

View Source
const (
	DEFAULT_PADDING = 100

	// Legend constants
	LEGEND_PADDING        = 20
	LEGEND_ITEM_SPACING   = 15
	LEGEND_ICON_SIZE      = 24
	LEGEND_FONT_SIZE      = 14
	LEGEND_CORNER_PADDING = 10
)

Variables

View Source
var BaseStylesheet string
View Source
var DEFAULT_DARK_THEME *int64 = nil // no theme selected
View Source
var LinkIcon string
View Source
var MarkdownCSS string
View Source
var TooltipIcon string

Functions

func EmbedFonts

func EmbedFonts(buf *bytes.Buffer, diagramHash, source string, fontFamily *d2fonts.FontFamily, monoFontFamily *d2fonts.FontFamily, corpus string)

func Render

func Render(diagram *d2target.Diagram, opts *RenderOpts) ([]byte, error)

func RenderLegend

func RenderLegend(buf *bytes.Buffer, diagram *d2target.Diagram, diagramHash string, theme *d2themes.Theme) error

func RenderMultiboard

func RenderMultiboard(diagram *d2target.Diagram, opts *RenderOpts) ([][]byte, error)

func RenderText

func RenderText(text string, x, height float64) string

func ThemeCSS

func ThemeCSS(diagramHash string, themeID *int64, darkThemeID *int64, overrides, darkOverrides *d2target.ThemeOverrides) (stylesheet string, err error)

TODO include only colors that are being used to reduce size

Types

type DiagramObject

type DiagramObject interface {
	GetID() string
	GetZIndex() int
}

type RenderOpts

type RenderOpts struct {
	Pad                *int64
	Sketch             *bool
	Center             *bool
	ThemeID            *int64
	DarkThemeID        *int64
	ThemeOverrides     *d2target.ThemeOverrides
	DarkThemeOverrides *d2target.ThemeOverrides
	Font               string
	// the svg will be scaled by this factor, if unset the svg will fit to screen
	Scale *float64

	// MasterID is passed when the diagram should use something other than its own hash for unique targeting
	// Currently, that's when multi-boards are collapsed
	MasterID    string
	NoXMLTag    *bool
	Salt        *string
	OmitVersion *bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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