Documentation ¶
Index ¶
- Constants
- Variables
- func AtomLookupString(s string) atom.Atom
- func BuildAttributeHTML(key string, values []string, delimiter string, htmlEscape bool) string
- func EscapeStrings(s []string) []string
- func HTMLToText(s string) string
- func HTMLToTextAtom(b []byte, policy *bluemonday.Policy, a atom.Atom) (string, error)
- func HTMLToTextCondensed(s string) string
- func HTMLToTextH1(b []byte, policy *bluemonday.Policy) (string, error)
- func NewTokenizerBytes(b []byte) *html.Tokenizer
- func NewTokenizerFile(name string) (*html.Tokenizer, error)
- func NextTextToken(z *html.Tokenizer, opts NextTokensOpts) (html.Token, error)
- func NextToken(z *html.Tokenizer, skipErrors bool, tokFilters ...html.Token) (html.Token, error)
- func ParseLink(tokens ...html.Token) (href string, desc string, err error)
- func SimplifyHTMLText(s string) string
- func StreamlineCRLFs(s string) string
- func TextToHTML(s string) string
- func TextToHTMLBr2(s string) string
- func TokenAttribute(token html.Token, attrName string) (string, error)
- func TokenMap(t html.Token) map[string]string
- func TokenMatchLeft(tokFilter, tok html.Token, attrValMatchinfo *stringsutil.MatchInfo) bool
- type AtomSet
- type Attributes
- func (attrs Attributes) Find(ns, key, val *string, n int) []html.Attribute
- func (attrs Attributes) FindOne(ns, key, val *string, errOnNone, errOnMulti bool) (html.Attribute, error)
- func (attrs Attributes) FindVal(ns, key *string) string
- func (attrs Attributes) FindVals(ns, key *string, n int) []string
- func (attrs Attributes) Index(attr html.Attribute, valMatch *stringsutil.MatchInfo) int
- func (attrs Attributes) IndexFunc(f func(a html.Attribute) bool) int
- func (attrs Attributes) IndexSimple(ns, key, val *string) int
- type Description
- type DescriptionList
- type DescriptionLists
- type Element
- type Link
- type NextTokensOpts
- type Text
- type Tokens
- func (tokens Tokens) Maps() []map[string]string
- func (tokens Tokens) MatchLeft(tok html.Token, attrValMatchinfo *stringsutil.MatchInfo) bool
- func (tokens Tokens) String() string
- func (tokens Tokens) Subset(opts NextTokensOpts) Tokens
- func (tokens Tokens) Table() [][]string
- func (tokens Tokens) Tokenizer() *html.Tokenizer
Constants ¶
const ( TagDiv = "div" AttributeAlt = "alt" AttributeClass = "class" AttributeHref = "href" AttributeName = "name" AttributeOnclick = "onclick" AttributeStyle = "style" DelimitSemicolon = ";" DelimitSpace = " " )
const ( Color2GreenHex = "#00FF2A" Color2YellowHex = "#DFDD13" Color2RedHex = "#FF0000" RingCentralOrangeHex = "#FF8800" RingCentralBlueHex = "#0073AE" RingCentralGreyHex = "#585858" )
Variables ¶
var ( ErrAttributeNameIsRequired = errors.New("attribute name is required") ErrTagNameIsRequired = errors.New("tag name is required") )
var ( ErrTokenNotFound = errors.New("token(s) not found") ErrTokenizerNotInitialized = errors.New("tokenizer not initialized") )
var ChartColor1 = [...]string{
"#3366CC",
"#DC3912",
"#FF9900",
"#109618",
"#990099",
"#3B3EAC",
"#0099C6",
"#DD4477",
"#66AA00",
"#B82E2E",
"#316395",
"#994499",
"#22AA99",
"#AAAA11",
"#6633CC",
"#E67300",
"#8B0707",
"#329262",
"#5574A6",
"#3B3EAC",
}
ChartColor1 is the color palette for Google Charts as collected by Craig Davis here: https://gist.github.com/there4/2579834
Functions ¶
func AtomLookupString ¶ added in v0.45.0
AtomLookupString returns the atom whose name is s. It returns zero if there is no such atom. The lookup is case sensitive.
func BuildAttributeHTML ¶ added in v0.40.12
func EscapeStrings ¶ added in v0.49.0
func HTMLToText ¶ added in v0.37.0
HTMLToText converts HTML to multi-line text.
func HTMLToTextAtom ¶ added in v0.43.0
func HTMLToTextCondensed ¶ added in v0.37.0
HTMLToTextCondensed removes HTML tags, unescapes HTML entities, and removes extra whitespace including non-breaking spaces.
func HTMLToTextH1 ¶ added in v0.43.0
func HTMLToTextH1(b []byte, policy *bluemonday.Policy) (string, error)
func NewTokenizerBytes ¶ added in v0.45.0
func NewTokenizerFile ¶ added in v0.45.0
func NextTextToken ¶ added in v0.45.0
NextTextToken uses `NextTokensOpts` specifically for `SkipErrors`, `StartFilter`, and `StartAttributeValueMatch`.
func SimplifyHTMLText ¶ added in v0.37.0
func StreamlineCRLFs ¶
func TextToHTML ¶ added in v0.37.0
func TextToHTMLBr2 ¶ added in v0.37.0
func TokenAttribute ¶ added in v0.45.0
func TokenMatchLeft ¶ added in v0.45.0
func TokenMatchLeft(tokFilter, tok html.Token, attrValMatchinfo *stringsutil.MatchInfo) bool
TokenMatchLeft returns true if the token matches the token filter.
Types ¶
type AtomSet ¶ added in v0.45.0
func NewAtomSet ¶ added in v0.45.0
func NewAtomSetString ¶ added in v0.45.0
func NewAtomSetStringMust ¶ added in v0.45.0
type Attributes ¶ added in v0.45.0
func (Attributes) Find ¶ added in v0.45.0
func (attrs Attributes) Find(ns, key, val *string, n int) []html.Attribute
func (Attributes) FindVal ¶ added in v0.45.0
func (attrs Attributes) FindVal(ns, key *string) string
func (Attributes) FindVals ¶ added in v0.45.0
func (attrs Attributes) FindVals(ns, key *string, n int) []string
func (Attributes) Index ¶ added in v0.50.0
func (attrs Attributes) Index(attr html.Attribute, valMatch *stringsutil.MatchInfo) int
Index returns the index location of the matching `html.Attribute`. If `*stringsutil.MatchInfo` is nil an exact match is required. If no match is found, `-1` is returned.`
func (Attributes) IndexFunc ¶ added in v0.50.0
func (attrs Attributes) IndexFunc(f func(a html.Attribute) bool) int
func (Attributes) IndexSimple ¶ added in v0.50.0
func (attrs Attributes) IndexSimple(ns, key, val *string) int
type Description ¶ added in v0.45.0
func (*Description) DescriptionString ¶ added in v0.45.0
func (d *Description) DescriptionString() string
func (*Description) Empty ¶ added in v0.45.0
func (d *Description) Empty() bool
func (*Description) Strings ¶ added in v0.45.0
func (d *Description) Strings() []string
func (*Description) TermString ¶ added in v0.45.0
func (d *Description) TermString() string
type DescriptionList ¶ added in v0.45.0
type DescriptionList []Description
func ParseDescriptionListTokens ¶ added in v0.45.0
func ParseDescriptionListTokens(toks ...html.Token) DescriptionList
func TokenizerDescriptionListNext ¶ added in v0.45.0
func TokenizerDescriptionListNext(z *html.Tokenizer) (DescriptionList, error)
func (DescriptionList) Strings ¶ added in v0.45.0
func (dl DescriptionList) Strings() [][]string
type DescriptionLists ¶ added in v0.45.0
type DescriptionLists []DescriptionList
func TokenizerDescriptionLists ¶ added in v0.45.0
func TokenizerDescriptionLists(z *html.Tokenizer) (DescriptionLists, error)
func (DescriptionLists) Strings ¶ added in v0.45.0
func (dls DescriptionLists) Strings() [][][]string
type Element ¶ added in v0.39.4
type Element struct { TagName string Attrs map[string][]string SelfClose bool InnerHTML []stringsutil.StringableWithErr }
func NewElement ¶ added in v0.39.4
func NewElement() *Element
func (*Element) AddAttribute ¶ added in v0.40.12
func (*Element) AddInnerHTML ¶ added in v0.40.13
func (el *Element) AddInnerHTML(innerHTML stringsutil.StringableWithErr)
func (*Element) AddInnerHTMLText ¶ added in v0.40.13
type NextTokensOpts ¶ added in v0.47.0
type Text ¶ added in v0.40.13
Text represents a text string that fulfills the `Stringable` interface.
type Tokens ¶ added in v0.45.0
func NextTokens ¶ added in v0.47.0
func NextTokens(z *html.Tokenizer, opts NextTokensOpts) (Tokens, error)
func (Tokens) MatchLeft ¶ added in v0.45.0
MatchLeft matches the supplied token with the tokens in the set. only the attributes in the set need to match for a `true` result. One one set token need to match for success.
func (Tokens) Subset ¶ added in v0.47.0
func (tokens Tokens) Subset(opts NextTokensOpts) Tokens