package svg

import "github.com/alecthomas/chroma/v2/formatters/svg"

Package svg contains an SVG formatter.

Index

Variables

var FontLiberationMono = "" /* 233250 byte string literal not displayed */

Liberation Mono as base64 encoded woff (SIL Open Font License)[https://en.wikipedia.org/wiki/Liberation_fonts]

Functions

func StyleEntryToSVG

func StyleEntryToSVG(e chroma.StyleEntry) string

StyleEntryToSVG converts a chroma.StyleEntry to SVG attributes.

Types

type FontFormat

type FontFormat int
const (
	WOFF FontFormat = iota
	WOFF2
	TRUETYPE
)

https://transfonter.org/formats

type Formatter

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

Formatter that generates SVG.

func New

func New(options ...Option) *Formatter

New SVG formatter.

func (*Formatter) Format

func (f *Formatter) Format(w io.Writer, style *chroma.Style, iterator chroma.Iterator) (err error)

type Option

type Option func(f *Formatter)

Option sets an option of the SVG formatter.

func EmbedFont

func EmbedFont(fontFamily string, font string, format FontFormat) Option

EmbedFont embeds given base64 encoded font

func EmbedFontFile

func EmbedFontFile(fontFamily string, fileName string) (option Option, err error)

EmbedFontFile embeds given font file

func FontFamily

func FontFamily(fontFamily string) Option

FontFamily sets the font-family.

Source Files

font_liberation_mono.go svg.go

Version
v2.16.0 (latest)
Published
Apr 3, 2025
Platform
darwin/amd64
Imports
8 packages
Last checked
25 minutes ago

Tools for package owners.