svg

package
Version: v2.1.0+incompatible Latest Latest
Warning

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

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

Documentation

Overview

Package svg minifies SVG1.1 following the specifications at http://www.w3.org/TR/SVG11/.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Minify

func Minify(m *minify.M, w io.Writer, r io.Reader, params map[string]string) error

Minify minifies SVG data, it reads from r and writes to w.

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)
}
Output:

Types

type Minifier

type Minifier struct {
	Decimals int
}

Minifier is an SVG minifier.

func (*Minifier) Minify

func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]string) error

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 NewPathData(o *Minifier) *PathData

func (*PathData) ShortenPathData

func (p *PathData) ShortenPathData(b []byte) []byte

type PathDataState

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

type Token added in v1.1.0

type Token struct {
	xml.TokenType
	Hash    svg.Hash
	Data    []byte
	Text    []byte
	AttrVal []byte
}

Token is a single token unit with an attribute value (if given) and hash of the data.

type TokenBuffer added in v1.1.0

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

TokenBuffer is a buffer that allows for token look-ahead.

func NewTokenBuffer added in v1.1.0

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 added in v1.1.0

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 added in v1.1.0

func (z *TokenBuffer) Shift() *Token

Shift returns the first element and advances position.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL