core

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package core provides the SVG optimization pipeline.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Path is the file path of the SVG being optimized (for plugin context).
	Path string

	// Multipass enables running the plugin chain up to 10 times
	// until the output size stops decreasing.
	Multipass bool

	// FloatPrecision sets the global float precision override.
	// nil means use plugin defaults.
	FloatPrecision *int

	// Plugins is the list of plugin configurations.
	// Default: ["preset-default"]
	Plugins []plugin.PluginConfig

	// Js2svg configures the stringifier output.
	Js2svg *svgast.StringifyOptions
}

Config defines the optimization configuration.

type Output

type Output struct {
	Data string
}

Output is the result of an optimization run.

func Optimize

func Optimize(input string, config *Config) (*Output, error)

Optimize runs the SVG optimization pipeline.

This matches SVGO's optimize() function: 1. Parse SVG string to XAST 2. Invoke plugins to transform the AST 3. Stringify XAST back to SVG 4. If multipass enabled, repeat until output size stops decreasing (max 10 passes)

Jump to

Keyboard shortcuts

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