Exemplo n.º 1
0
// NextStartTag skips everything until we find a start tag of the given names.
func NextStartTag(t *html.Tokenizer, tagNames ...string) (html.Token, error) {
	for {
		switch t.Next() {
		case html.ErrorToken:
			return html.Token{}, t.Err()
		case html.SelfClosingTagToken, html.StartTagToken:
			tt := t.Token()
			for _, v := range tagNames {
				if v == tt.Data {
					return tt, nil
				}
			}
		}
	}
	panic("unreachable")
}