Documentation
¶
Overview ¶
Package html minifies HTML5 following the specifications at http://www.w3.org/TR/html5/syntax.html.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Minify ¶
Minify minifies HTML data, it reads from r and writes to w.
Example ¶
m := minify.New()
m.AddFunc("text/html", Minify)
m.AddFunc("text/css", css.Minify)
m.AddFunc("text/javascript", js.Minify)
m.AddFunc("image/svg+xml", svg.Minify)
m.AddFuncRegexp(regexp.MustCompile("[/+]json$"), json.Minify)
m.AddFuncRegexp(regexp.MustCompile("[/+]xml$"), xml.Minify)
if err := m.Minify("text/html", os.Stdout, os.Stdin); err != nil {
fmt.Println("minify.Minify:", err)
}
Types ¶
type Token ¶ added in v1.1.0
type Token struct {
html.TokenType
Hash html.Hash
Data []byte
AttrVal []byte
Traits traits
// contains filtered or unexported fields
}
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 *html.Lexer) *TokenBuffer
NewTokenBuffer returns a new TokenBuffer.
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.
Click to show internal directories.
Click to hide internal directories.