package svg
import "github.com/tdewolff/minify/svg"
Package svg minifies SVG1.1 following the specifications at http://www.w3.org/TR/SVG11/.
Index ¶
- Variables
- func Minify(m *minify.M, w io.Writer, r io.Reader, params map[string]string) error
- type Minifier
- type PathData
- type PathDataState
- type Token
- type TokenBuffer
Examples ¶
Variables ¶
var DefaultMinifier = &Minifier{Decimals: -1}
DefaultMinifier is the default minifier.
Functions ¶
func Minify ¶
Minify minifies SVG data, it reads from r and writes to w.
Code:
Example¶
{
m := minify.New()
m.AddFunc("image/svg+xml", Minify)
m.AddFunc("text/css", css.Minify)
if err := m.Minify("image/svg+xml", os.Stdout, os.Stdin); err != nil {
panic(err)
}
}
Types ¶
type Minifier ¶
type Minifier struct { Decimals int }
Minifier is an SVG minifier.
func (*Minifier) Minify ¶
Minify minifies SVG data, it reads from r and writes to w.
type PathData ¶
type PathData struct {
// contains filtered or unexported fields
}
func NewPathData ¶
func (*PathData) ShortenPathData ¶
ShortenPathData takes a full pathdata string and returns a shortened version. The original string is overwritten. It parses all commands (M, A, Z, ...) and coordinates (numbers) and calls copyInstruction for each command.
type PathDataState ¶
type PathDataState struct {
// contains filtered or unexported fields
}
type Token ¶
Token is a single token unit with an attribute value (if given) and hash of the data.
type TokenBuffer ¶
type TokenBuffer struct {
// contains filtered or unexported fields
}
TokenBuffer is a buffer that allows for token look-ahead.
func NewTokenBuffer ¶
func NewTokenBuffer(l *xml.Lexer) *TokenBuffer
NewTokenBuffer returns a new TokenBuffer.
func (*TokenBuffer) Attributes ¶
func (z *TokenBuffer) Attributes(hashes ...svg.Hash) ([]*Token, *Token)
Attributes extracts the gives attribute hashes from a tag. It returns in the same order pointers to the requested token data or nil.
func (*TokenBuffer) Peek ¶
func (z *TokenBuffer) Peek(pos int) *Token
Peek returns the ith element and possibly does an allocation. Peeking past an error will panic.
func (*TokenBuffer) Shift ¶
func (z *TokenBuffer) Shift() *Token
Shift returns the first element and advances position.
Source Files ¶
buffer.go pathdata.go svg.go table.go
- Version
- v2.3.5+incompatible
- Published
- Jun 8, 2018
- Platform
- darwin/amd64
- Imports
- 11 packages
- Last checked
- 5 hours ago –
Tools for package owners.