common

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TmplDir  = "template"
	TmplFile = "template.html"
	Selector = "body > pre > svg"

	FORMAT_SVG  = "svg"
	FORMAT_MD   = "md"
	FORMAT_PDF  = "pdf"
	FORMAT_PNG  = "png"
	FORMAT_WEBP = "webp"
	FORMAT_JPEG = "jpeg"

	THEME_DEFAULT = "default"
	THEME_FOREST  = "forest"
	THEME_DARK    = "dark"
	THEME_NEUTRAL = "neutral"
	THEME_NULL    = "null"
)

Variables

View Source
var (
	ErrInvalidInputPath    = fmt.Errorf("input path cannot be empty")
	ErrFileDoesNotExists   = fmt.Errorf("input file does not exists")
	ErrInvalidOutputFormat = fmt.Errorf("output file must end with md/svg/png or pdf")
	ErrNotSupported        = fmt.Errorf("this is not supported yet")
	ErrConfigNotFound      = fmt.Errorf("config is not found")
	ErrInvalidTheme        = fmt.Errorf("invalid theme")
	ErrInvalidCSSFilePath  = fmt.Errorf("invalid CSS path")

	ValidThemes = []string{THEME_DEFAULT, THEME_FOREST, THEME_DARK, THEME_NEUTRAL, THEME_NULL}

	ValidOutputFormats = []string{FORMAT_SVG, FORMAT_MD, FORMAT_PDF, FORMAT_PNG, FORMAT_JPEG, FORMAT_WEBP}

	MD_REGEX = regexp.MustCompile("```mermaid[\\S\\s]*?```")
)

Functions

func EscapeJS added in v0.0.2

func EscapeJS(val string) string

func GetPtrOf added in v0.0.2

func GetPtrOf[T any](val T) *T

Types

type Config

type Config struct {
	Theme        string
	Width        int
	Height       int
	InputPath    string
	OutputPath   string
	OutputFormat string
	BgColor      string
	ConfigFile   string
	CssFile      string
	Scale        int
	PDFFit       bool
	QuietMode    bool
	DarkMode     bool
	FontFamily   string
}

func NewConfig

func NewConfig(
	theme string,
	width int,
	height int,
	inputPath string,
	outputPath string,
	outputFormat string,
	bgColor string,
	configFile string,
	cssFile string,
	scale int,
	pdfFit bool,
	quietMode bool,
	darkMode bool,
	fontFamily string,
) (*Config, error)

func (*Config) Clone added in v0.0.2

func (c *Config) Clone() *Config

func (*Config) ToTemplate added in v0.0.2

func (c *Config) ToTemplate() *Template

type Template

type Template struct {
	Mermaid    string
	BgColor    string
	Theme      string
	IsDarkMode bool
	FontFamily string
	CSSPath    string
}

Jump to

Keyboard shortcuts

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