package xml

import "github.com/tdewolff/minify/xml"

Package xml minifies XML1.0 following the specifications at http://www.w3.org/TR/xml/.

Index

Examples

Functions

func Minify

func Minify(m minify.Minifier, _ string, w io.Writer, r io.Reader) error

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

Example

Code:

{
	m := minify.New()
	m.AddFuncRegexp(regexp.MustCompile("[/+]xml$"), Minify)

	if err := m.Minify("text/xml", os.Stdout, os.Stdin); err != nil {
		fmt.Println("minify.Minify:", err)
	}
}

Types

type Token

type Token struct {
	xml.TokenType
	Data    []byte
	AttrVal []byte
	// contains filtered or unexported fields
}

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) 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 xml.go

Version
v1.1.0 (latest)
Published
Nov 2, 2015
Platform
js/wasm
Imports
4 packages
Last checked
2 hours ago

Tools for package owners.