package xml
import "github.com/tdewolff/minify/v2/xml"
Package xml minifies XML1.0 following the specifications at http://www.w3.org/TR/xml/.
Index ¶
- Variables
- func Minify(m *minify.M, w io.Writer, r io.Reader, params map[string]string) error
- type Minifier
- type Token
- type TokenBuffer
Examples ¶
Variables ¶
var EntitiesMap = map[string][]byte{ "apos": []byte("'"), "gt": []byte(">"), "quot": []byte("\""), }
EntitiesMap are all named character entities.
TextRevEntitiesMap is a map of escapes.
Functions ¶
func Minify ¶
Minify minifies XML data, it reads from r and writes to w.
Code:
Example¶
{
m := minify.New()
m.AddFuncRegexp(regexp.MustCompile("[/+]xml$"), Minify)
if err := m.Minify("text/xml", os.Stdout, os.Stdin); err != nil {
panic(err)
}
}
Types ¶
type Minifier ¶
type Minifier struct { KeepWhitespace bool }
Minifier is an XML minifier.
func (*Minifier) Minify ¶
Minify minifies XML data, it reads from r and writes to w.
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) 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 ¶
- Version
- v2.21.3 (latest)
- Published
- Jan 14, 2025
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 4 days ago –
Tools for package owners.