Documentation
¶
Overview ¶
Package tools provides numeric and string utility functions ported from SVGO's lib/svgo/tools.js.
Index ¶
- func CleanupOutData(data []float64, params *CleanupOutDataParams, command byte) string
- func DecodeSVGDataURI(str string) string
- func EncodeSVGDataURI(str string, dataType string) string
- func FindReferences(attribute, value string) []string
- func HasScripts(node *svgast.Element) bool
- func IncludesURLReference(body string) bool
- func RemoveLeadingZero(value float64) string
- func ToFixed(num float64, precision int) float64
- type CleanupOutDataParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupOutData ¶
func CleanupOutData(data []float64, params *CleanupOutDataParams, command byte) string
CleanupOutData converts a row of numbers to an optimized string view.
Example: [0, -1, .5, .5] → "0-1 .5.5"
func DecodeSVGDataURI ¶
DecodeSVGDataURI decodes a data URI back to an SVG string.
func EncodeSVGDataURI ¶
EncodeSVGDataURI encodes an SVG string as a data URI. Type can be "base64", "enc" (URI encoded), or "unenc" (unencoded).
func FindReferences ¶
FindReferences extracts all URL/href references from an attribute value.
func HasScripts ¶
HasScripts checks if a node contains any scripts. This checks the node's own properties, not parents or children.
func IncludesURLReference ¶
IncludesURLReference checks if a string contains a url(#ref) reference.
func RemoveLeadingZero ¶
RemoveLeadingZero removes the leading zero from floating-point numbers.
Examples: 0.5 → ".5", -0.5 → "-.5"
Types ¶
type CleanupOutDataParams ¶
type CleanupOutDataParams struct {
NoSpaceAfterFlags bool
LeadingZero bool
NegativeExtraSpace bool
}
CleanupOutDataParams controls numeric output formatting.