func tHTMLCmt(c context, s []byte) (context, int) {
	if i := bytes.Index(s, commentEnd); i != -1 {
		return context{}, i + 3
	}
	return c, len(s)
}
tHTMLCmt is the context transition function for stateHTMLCmt.
package template
import (
	"bytes"
	"strings"
)
var transitionFunc = [...]func(context, []byte) (context, int){
	stateText:               tText,
	stateSpecialElementBody: tSpecialTagEnd,
	stateTag:                tTag,
	stateAttrName:           tAttrName,
	stateAfterName:          tAfterName,
	stateBeforeValue:        tBeforeValue,
	stateHTMLCmt:            tHTMLCmt,
	stateAttr:               tAttr,
	stateError:              tError,
}
var commentStart = []byte("<!--")
var commentEnd = []byte("-->")
func tText(c context, s []byte) (context, int) {
	k := 0
	for {
		i := k + bytes.IndexByte(s[k:], '<')
		if i < k || i+1 == len(s) {
			return c, len(s)
		} else if i+4 <= len(s) && bytes.Equal(commentStart, s[i:i+4]) {
			return context{state: stateHTMLCmt}, i + 4
		}
		i++
		end := false
		if s[i] == '/' {
			if i+1 == len(s) {
				return c, len(s)
			}
			end, i = true, i+1
		}
		j, e := eatTagName(s, i)
		if j != i {
			ret := context{state: stateTag}
			if !end {
				ret.element = e
			}
			return ret, j
		}
		k = j
	}
}
var specialElements = map[string]bool{
	"script":   true,
	"style":    true,
	"textarea": true,
	"title":    true,
}
var voidElements = map[string]bool{
	"area":   true,
	"base":   true,
	"br":     true,
	"col":    true,
	"embed":  true,
	"hr":     true,
	"img":    true,
	"input":  true,
	"keygen": true,
	"link":   true,
	"meta":   true,
	"param":  true,
	"source": true,
	"track":  true,
	"wbr":    true,
}
func tTag(c context, s []byte) (context, int) {
	i := eatWhiteSpace(s, 0)
	if i == len(s) {
		return c, len(s)
	}
	if s[i] == '>' {
		ret := context{
			state:      stateText,
			element:    c.element,
			scriptType: c.scriptType,
			linkRel:    c.linkRel,
		}
		if specialElements[c.element.name] {
			ret.state = stateSpecialElementBody
		}
		if c.element.name != "" && voidElements[c.element.name] {
			ret.element = element{}
			ret.scriptType = ""
			ret.linkRel = ""
		}
		return ret, i + 1
	}
	j, err := eatAttrName(s, i)
	if err != nil {
		return context{state: stateError, err: err}, len(s)
	}
	state := stateTag
	if i == j {
		return context{
			state: stateError,
			err:   errorf(ErrBadHTML, nil, 0, "expected space, attr name, or end of tag, but got %q", s[i:]),
		}, len(s)
	}
	if j == len(s) {
		state = stateAttrName
	} else {
		state = stateAfterName
	}
	return context{
		state:   state,
		element: c.element,
		attr:    attr{name: strings.ToLower(string(s[i:j]))},
		linkRel: c.linkRel,
	}, j
}
func tAttrName(c context, s []byte) (context, int) {
	i, err := eatAttrName(s, 0)
	if err != nil {
		return context{state: stateError, err: err}, len(s)
	} else if i != len(s) {
		c.state = stateAfterName
	}
	return c, i
}
func tAfterName(c context, s []byte) (context, int) {
	i := eatWhiteSpace(s, 0)
	if i == len(s) {
		return c, len(s)
	} else if s[i] != '=' {
		c.state = stateTag
		return c, i
	}
	c.state = stateBeforeValue
	return c, i + 1
}
func tBeforeValue(c context, s []byte) (context, int) {
	i := eatWhiteSpace(s, 0)
	if i == len(s) {
		return c, len(s)
	}
	delim := delimSpaceOrTagEnd
	switch s[i] {
	case '\'':
		delim, i = delimSingleQuote, i+1
	case '"':
		delim, i = delimDoubleQuote, i+1
	}
	c.state, c.delim = stateAttr, delim
	return c, i
}