tokenizer

package
v0.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttrHref = "href"
)

Variables

View Source
var TokenNotFound = errors.New("token not found")

Functions

func NextStartToken

func NextStartToken(z *html.Tokenizer, skipErrors bool, htmlAtoms ...atom.Atom) (html.Token, error)

func NextTextToken

func NextTextToken(z *html.Tokenizer, skipErrors bool, htmlAtoms ...atom.Atom) (html.Token, error)

func NextTokenMatch

func NextTokenMatch(z *html.Tokenizer, skipErrors, includeChain, includeMatch bool, filters ...TokenFilter) ([]html.Token, error)

NextTokenMatch returns a string of matches. `includeMatch` is only used when `includeChain` is included.

func ParseLink(tokens ...html.Token) (href string, desc string, err error)

func TokenAttribute

func TokenAttribute(token html.Token, attrName string) (string, error)

func TokensBetween

func TokensBetween(z *html.Tokenizer, skipErrors, inclusive bool, begin, end TokenFilters) ([]html.Token, error)

func TokensBetweenAtom

func TokensBetweenAtom(z *html.Tokenizer, skipErrors, inclusive bool, htmlAtom atom.Atom) ([]html.Token, error)

TokensBetweenAtom returns the tokens that represent the `innerHtml` between a start and end tag token.

Types

type AtomSet

type AtomSet struct {
	Atoms map[string]atom.Atom
}

func NewAtomSet

func NewAtomSet(htmlAtoms ...atom.Atom) AtomSet

func (AtomSet) Add

func (set AtomSet) Add(htmlAtoms ...atom.Atom)

func (AtomSet) Exists

func (set AtomSet) Exists(htmlAtom atom.Atom) bool

func (AtomSet) Len

func (set AtomSet) Len() int

func (AtomSet) Names

func (set AtomSet) Names() []string

type Attributes

type Attributes []html.Attribute

func (Attributes) GetOne

func (attrs Attributes) GetOne(attributeKey string) (html.Attribute, error)

type TokenFilter

type TokenFilter struct {
	TokenType html.TokenType
	AtomSet   AtomSet
}

find next <tr> or </table>

type TokenFilters

type TokenFilters []TokenFilter

func (TokenFilters) ByTokenType

func (filters TokenFilters) ByTokenType(tt html.TokenType) []TokenFilter

type Tokens

type Tokens []html.Token

func (Tokens) String

func (tokens Tokens) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL