Documentation ¶
Index ¶
- Variables
- func IsVoidElement(tag Tag) bool
- type Attr
- type Converter
- type DefaultConsumer
- func (consumer *DefaultConsumer) ConsumeAttrs(tag Tag, token html.Token) error
- func (consumer *DefaultConsumer) ConsumeElementBody(tag Tag, tokenizer *html.Tokenizer, token html.Token, tagName string) (html.Token, error)
- func (consumer *DefaultConsumer) ConsumeToken(parent Tag, tokenizer *html.Tokenizer, token html.Token) (html.Token, error)
- func (consumer *DefaultConsumer) ConsumeTokenImpl(parent Tag, tokenizer *html.Tokenizer, token html.Token) (html.Token, error)
- func (consumer *DefaultConsumer) SetTagAttrsConsumer(attrsConsumer TagAttrsConsumer)
- type Tag
- type TagAttrsConsumer
- type TextToken
- type Token
- type TokenConsumer
- type TokenType
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidTokenType = errors.New("invalid token type")
View Source
var VoidElements = []string{
"area",
"base",
"br",
"col",
"embed",
"hr",
"img",
"input",
"keygen",
"link",
"meta",
"param",
"source",
"track",
"wbr",
}
VoidElements is start with html.StartTagToken, but it is not with html.EndTagToken. see https://www.w3.org/TR/html5/syntax.html#void-elements
Functions ¶
func IsVoidElement ¶
Types ¶
type Converter ¶
type Converter interface { DefaultConsumer() TokenConsumer RaiseErrorOnInvalidEndTag() bool ConsumerByTokenType(tokenType html.TokenType) TokenConsumer ConsumerByTagName(tagName string) TokenConsumer SetRaiseErrorOnInvalidEndTag(newVal bool) SetDefaultConsumer(consumer TokenConsumer) SetTokenTypeConsumer(tokenType html.TokenType, consumer TokenConsumer) SetTagNameConsumer(tagName string, consumer TokenConsumer) Parse(r io.Reader) (Tag, error) Convert(r io.Reader) (string, error) }
func NewConverter ¶
func NewConverter() Converter
type DefaultConsumer ¶
type DefaultConsumer struct {
// contains filtered or unexported fields
}
func (*DefaultConsumer) ConsumeAttrs ¶
func (consumer *DefaultConsumer) ConsumeAttrs(tag Tag, token html.Token) error
func (*DefaultConsumer) ConsumeElementBody ¶
func (*DefaultConsumer) ConsumeToken ¶
func (*DefaultConsumer) ConsumeTokenImpl ¶
func (*DefaultConsumer) SetTagAttrsConsumer ¶
func (consumer *DefaultConsumer) SetTagAttrsConsumer(attrsConsumer TagAttrsConsumer)
type Tag ¶
type Tag interface { Token IsDocumentRoot() bool Name() string Tokens() []Token SetTokens(tokens []Token) AddChildTokens(childlen ...Token) UnshiftChileToken(token Token) ReplateChildToken(from Token, to Token) GetElementsByTagName(tagName string) []Tag FindAncestor(tagName string) Tag Attrs() []*Attr SetAttrs(attrs []*Attr) AddAttr(key, value string) GetAttr(attrKey string) *Attr RemoveAttr(attrKey string) HasAttr(attrKey string) bool HasAttrValue(attrKey string, attrValue string) bool HasAttrValueCaseInsensitive(attrKey string, attrValue string) bool AddText(text string) AddComment(text string) }
func CreateDocumentRoot ¶
func CreateDocumentRoot() Tag
func CreateElement ¶
type TagAttrsConsumer ¶
type Token ¶
type Token interface { Type() TokenType Parent() Tag BuildHTML(buf *bytes.Buffer) Tag() Tag TextToken() TextToken // contains filtered or unexported methods }
func CreateCommentToken ¶
func CreateDoctypeToken ¶
func CreateTextToken ¶
type TokenConsumer ¶
type TokenConsumer interface { // ConsumeToken は渡されたTokenをキリのいいところまで処理し、次に処理するべきTokenを返す ConsumeToken(parent Tag, tokenizer *html.Tokenizer, token html.Token) (html.Token, error) }
TokenConsumer はHTMLのTokenを食べて何らかの文字列を組み立てる
func NewVacuumConsumer ¶
func NewVacuumConsumer(conv Converter) TokenConsumer
NewVacuumConsumer は渡されたTokenから始まる要素を全て捨てるTokenConsumerを返す
Click to show internal directories.
Click to hide internal directories.