Documentation ¶
Index ¶
- func CssUnescape(b []byte) string
- func Filter(nodes []*html.Node, m Matcher) (result []*html.Node)
- func IsPseudoElement(sel Sel) bool
- func Query(n *html.Node, m Matcher) *html.Node
- func QueryAll(n *html.Node, m Matcher) []*html.Node
- type ActivePseudoClassSelector
- type AttrSelector
- type CheckedPseudoClassSelector
- type ClassSelector
- type CombinedSelector
- type CompoundSelector
- func (t CompoundSelector) Match(n *html.Node) bool
- func (c CompoundSelector) PseudoElement() string
- func (c CompoundSelector) PseudoElements() []Sel
- func (c CompoundSelector) PseudoElementsString() string
- func (c CompoundSelector) Selectors() []Sel
- func (s CompoundSelector) Specificity() Specificity
- func (c CompoundSelector) String() string
- type ContainsPseudoClassSelector
- func (c ContainsPseudoClassSelector) IsClass(n *html.Node) bool
- func (s ContainsPseudoClassSelector) Match(n *html.Node) bool
- func (c ContainsPseudoClassSelector) PseudoElement() string
- func (s ContainsPseudoClassSelector) Specificity() Specificity
- func (c ContainsPseudoClassSelector) String() string
- type CssDeclaration
- type CssRule
- type DisabledPseudoClassSelector
- func (c DisabledPseudoClassSelector) IsClass(n *html.Node) bool
- func (s DisabledPseudoClassSelector) Match(n *html.Node) bool
- func (c DisabledPseudoClassSelector) PseudoElement() string
- func (s DisabledPseudoClassSelector) Specificity() Specificity
- func (c DisabledPseudoClassSelector) String() string
- type EmptyElementPseudoClassSelector
- func (c EmptyElementPseudoClassSelector) IsClass(n *html.Node) bool
- func (s EmptyElementPseudoClassSelector) Match(n *html.Node) bool
- func (c EmptyElementPseudoClassSelector) PseudoElement() string
- func (s EmptyElementPseudoClassSelector) Specificity() Specificity
- func (c EmptyElementPseudoClassSelector) String() string
- type EnabledPseudoClassSelector
- type FocusPseudoClassSelector
- type HoverPseudoClassSelector
- type IdSelector
- type InputPseudoClassSelector
- type IsPseudoClassSelector
- type LangPseudoClassSelector
- type LinkPseudoClassSelector
- type Matcher
- type NthPseudoClassSelector
- type OnlyChildPseudoClassSelector
- func (c OnlyChildPseudoClassSelector) IsClass(n *html.Node) bool
- func (s OnlyChildPseudoClassSelector) Match(n *html.Node) bool
- func (c OnlyChildPseudoClassSelector) PseudoElement() string
- func (s OnlyChildPseudoClassSelector) Specificity() Specificity
- func (c OnlyChildPseudoClassSelector) String() string
- type PopoverPseudoClassSelector
- type ReadOnlyPseudoClassSelector
- func (c ReadOnlyPseudoClassSelector) IsClass(n *html.Node) bool
- func (s ReadOnlyPseudoClassSelector) Match(n *html.Node) bool
- func (c ReadOnlyPseudoClassSelector) PseudoElement() string
- func (s ReadOnlyPseudoClassSelector) Specificity() Specificity
- func (c ReadOnlyPseudoClassSelector) String() string
- type RegexpPseudoClassSelector
- type RelativePseudoClassSelector
- type RootPseudoClassSelector
- type Sel
- type SelectorGroup
- type Specificity
- type TagSelector
- type TargetPseudoClassSelector
- type VisitedPseudoClassSelector
- type WherePseudoClassSelector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CssUnescape ¶
func IsPseudoElement ¶
Types ¶
type ActivePseudoClassSelector ¶
type ActivePseudoClassSelector struct {
// contains filtered or unexported fields
}
func (ActivePseudoClassSelector) Match ¶
func (s ActivePseudoClassSelector) Match(n *html.Node) bool
func (ActivePseudoClassSelector) PseudoElement ¶
func (c ActivePseudoClassSelector) PseudoElement() string
func (ActivePseudoClassSelector) Specificity ¶
func (s ActivePseudoClassSelector) Specificity() Specificity
func (ActivePseudoClassSelector) String ¶
func (c ActivePseudoClassSelector) String() string
type AttrSelector ¶
type AttrSelector struct {
// contains filtered or unexported fields
}
func (AttrSelector) Match ¶
func (t AttrSelector) Match(n *html.Node) bool
Matches elements by attribute value.
func (AttrSelector) PseudoElement ¶
func (c AttrSelector) PseudoElement() string
func (AttrSelector) Specificity ¶
func (c AttrSelector) Specificity() Specificity
func (AttrSelector) String ¶
func (c AttrSelector) String() string
type CheckedPseudoClassSelector ¶
type CheckedPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (CheckedPseudoClassSelector) Match ¶
func (s CheckedPseudoClassSelector) Match(n *html.Node) bool
func (CheckedPseudoClassSelector) PseudoElement ¶
func (c CheckedPseudoClassSelector) PseudoElement() string
func (CheckedPseudoClassSelector) Specificity ¶
func (s CheckedPseudoClassSelector) Specificity() Specificity
func (CheckedPseudoClassSelector) String ¶
func (c CheckedPseudoClassSelector) String() string
type ClassSelector ¶
type ClassSelector struct {
Class string
}
func (ClassSelector) Match ¶
func (t ClassSelector) Match(n *html.Node) bool
Matches elements by class attribute.
func (ClassSelector) PseudoElement ¶
func (c ClassSelector) PseudoElement() string
func (ClassSelector) Specificity ¶
func (c ClassSelector) Specificity() Specificity
func (ClassSelector) String ¶
func (c ClassSelector) String() string
type CombinedSelector ¶
type CombinedSelector struct {
// contains filtered or unexported fields
}
CombinedSelector is a selector that combines two selectors with a combinator. If the selector is more than two parts, the first contains all but the last part, and the second contains the last part.
func (CombinedSelector) First ¶
func (c CombinedSelector) First() Sel
func (CombinedSelector) PseudoElement ¶
func (c CombinedSelector) PseudoElement() string
on combinedSelector, a pseudo-element only makes sense on the last selector, although others increase specificity.
func (CombinedSelector) Second ¶
func (c CombinedSelector) Second() Sel
func (CombinedSelector) Specificity ¶
func (s CombinedSelector) Specificity() Specificity
func (CombinedSelector) String ¶
func (c CombinedSelector) String() string
type CompoundSelector ¶
type CompoundSelector struct {
// contains filtered or unexported fields
}
func (CompoundSelector) Match ¶
func (t CompoundSelector) Match(n *html.Node) bool
Matches elements if each sub-selectors matches.
func (CompoundSelector) PseudoElement ¶
func (c CompoundSelector) PseudoElement() string
func (CompoundSelector) PseudoElements ¶
func (c CompoundSelector) PseudoElements() []Sel
func (CompoundSelector) PseudoElementsString ¶
func (c CompoundSelector) PseudoElementsString() string
func (CompoundSelector) Selectors ¶
func (c CompoundSelector) Selectors() []Sel
func (CompoundSelector) Specificity ¶
func (s CompoundSelector) Specificity() Specificity
func (CompoundSelector) String ¶
func (c CompoundSelector) String() string
type ContainsPseudoClassSelector ¶
type ContainsPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (ContainsPseudoClassSelector) Match ¶
func (s ContainsPseudoClassSelector) Match(n *html.Node) bool
func (ContainsPseudoClassSelector) PseudoElement ¶
func (c ContainsPseudoClassSelector) PseudoElement() string
func (ContainsPseudoClassSelector) Specificity ¶
func (s ContainsPseudoClassSelector) Specificity() Specificity
func (ContainsPseudoClassSelector) String ¶
func (c ContainsPseudoClassSelector) String() string
type CssDeclaration ¶
type CssDeclaration struct { Property string // Property is the property for the declaration (e.g., "color") Value string // Value is the value for the declaration (e.g., "red") }
CssDeclaration represents a CSS declaration, which includes a property and a value.
type CssRule ¶
type CssRule struct { Selector Sel // Selector is the selector for the rule Declarations []CssDeclaration // Declarations is a list of declarations for the rule (e.g., property-value pairs) // contains filtered or unexported fields }
CssRule represents a CSS rule, which includes a selector and a list of declarations. It also includes a condition, which is used to represent the condition of an at-rule (e.g., @media). The condition can also be a pseudo-element or pseudo-class for a compound selector (e.g., :hover, ::before).
func (CssRule) GetCondition ¶
func (CssRule) GetSelector ¶
func (CssRule) ToCssFormat ¶
type DisabledPseudoClassSelector ¶
type DisabledPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (DisabledPseudoClassSelector) Match ¶
func (s DisabledPseudoClassSelector) Match(n *html.Node) bool
func (DisabledPseudoClassSelector) PseudoElement ¶
func (c DisabledPseudoClassSelector) PseudoElement() string
func (DisabledPseudoClassSelector) Specificity ¶
func (s DisabledPseudoClassSelector) Specificity() Specificity
func (DisabledPseudoClassSelector) String ¶
func (c DisabledPseudoClassSelector) String() string
type EmptyElementPseudoClassSelector ¶
type EmptyElementPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (EmptyElementPseudoClassSelector) Match ¶
func (s EmptyElementPseudoClassSelector) Match(n *html.Node) bool
Matches empty elements.
func (EmptyElementPseudoClassSelector) PseudoElement ¶
func (c EmptyElementPseudoClassSelector) PseudoElement() string
func (EmptyElementPseudoClassSelector) Specificity ¶
func (s EmptyElementPseudoClassSelector) Specificity() Specificity
func (EmptyElementPseudoClassSelector) String ¶
func (c EmptyElementPseudoClassSelector) String() string
type EnabledPseudoClassSelector ¶
type EnabledPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (EnabledPseudoClassSelector) Match ¶
func (s EnabledPseudoClassSelector) Match(n *html.Node) bool
func (EnabledPseudoClassSelector) PseudoElement ¶
func (c EnabledPseudoClassSelector) PseudoElement() string
func (EnabledPseudoClassSelector) Specificity ¶
func (s EnabledPseudoClassSelector) Specificity() Specificity
func (EnabledPseudoClassSelector) String ¶
func (c EnabledPseudoClassSelector) String() string
type FocusPseudoClassSelector ¶
type FocusPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (FocusPseudoClassSelector) PseudoElement ¶
func (c FocusPseudoClassSelector) PseudoElement() string
func (FocusPseudoClassSelector) Specificity ¶
func (s FocusPseudoClassSelector) Specificity() Specificity
func (FocusPseudoClassSelector) String ¶
func (c FocusPseudoClassSelector) String() string
type HoverPseudoClassSelector ¶
type HoverPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (HoverPseudoClassSelector) PseudoElement ¶
func (c HoverPseudoClassSelector) PseudoElement() string
func (HoverPseudoClassSelector) Specificity ¶
func (s HoverPseudoClassSelector) Specificity() Specificity
func (HoverPseudoClassSelector) String ¶
func (c HoverPseudoClassSelector) String() string
type IdSelector ¶
type IdSelector struct {
// contains filtered or unexported fields
}
func (IdSelector) Match ¶
func (t IdSelector) Match(n *html.Node) bool
Matches elements by id attribute.
func (IdSelector) PseudoElement ¶
func (c IdSelector) PseudoElement() string
func (IdSelector) Specificity ¶
func (c IdSelector) Specificity() Specificity
func (IdSelector) String ¶
func (c IdSelector) String() string
type InputPseudoClassSelector ¶
type InputPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (InputPseudoClassSelector) Match ¶
func (s InputPseudoClassSelector) Match(n *html.Node) bool
Matches input, select, textarea and button elements.
func (InputPseudoClassSelector) PseudoElement ¶
func (c InputPseudoClassSelector) PseudoElement() string
func (InputPseudoClassSelector) Specificity ¶
func (s InputPseudoClassSelector) Specificity() Specificity
func (InputPseudoClassSelector) String ¶
func (c InputPseudoClassSelector) String() string
type IsPseudoClassSelector ¶
type IsPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (IsPseudoClassSelector) PseudoElement ¶
func (c IsPseudoClassSelector) PseudoElement() string
func (IsPseudoClassSelector) Selectors ¶
func (c IsPseudoClassSelector) Selectors() []Sel
func (IsPseudoClassSelector) Specificity ¶
func (s IsPseudoClassSelector) Specificity() Specificity
func (IsPseudoClassSelector) String ¶
func (c IsPseudoClassSelector) String() string
type LangPseudoClassSelector ¶
type LangPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (LangPseudoClassSelector) PseudoElement ¶
func (c LangPseudoClassSelector) PseudoElement() string
func (LangPseudoClassSelector) Specificity ¶
func (s LangPseudoClassSelector) Specificity() Specificity
func (LangPseudoClassSelector) String ¶
func (c LangPseudoClassSelector) String() string
type LinkPseudoClassSelector ¶
type LinkPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (LinkPseudoClassSelector) Match ¶
func (s LinkPseudoClassSelector) Match(n *html.Node) bool
Match implements :link
func (LinkPseudoClassSelector) PseudoElement ¶
func (c LinkPseudoClassSelector) PseudoElement() string
func (LinkPseudoClassSelector) Specificity ¶
func (s LinkPseudoClassSelector) Specificity() Specificity
func (LinkPseudoClassSelector) String ¶
func (c LinkPseudoClassSelector) String() string
type Matcher ¶
Matcher is the interface for basic selector functionality. Match returns whether a selector matches n.
type NthPseudoClassSelector ¶
type NthPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (NthPseudoClassSelector) PseudoElement ¶
func (c NthPseudoClassSelector) PseudoElement() string
func (NthPseudoClassSelector) Specificity ¶
func (s NthPseudoClassSelector) Specificity() Specificity
func (NthPseudoClassSelector) String ¶
func (c NthPseudoClassSelector) String() string
type OnlyChildPseudoClassSelector ¶
type OnlyChildPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (OnlyChildPseudoClassSelector) Match ¶
func (s OnlyChildPseudoClassSelector) Match(n *html.Node) bool
Match implements :only-child. If `ofType` is true, it implements :only-of-type instead.
func (OnlyChildPseudoClassSelector) PseudoElement ¶
func (c OnlyChildPseudoClassSelector) PseudoElement() string
func (OnlyChildPseudoClassSelector) Specificity ¶
func (s OnlyChildPseudoClassSelector) Specificity() Specificity
func (OnlyChildPseudoClassSelector) String ¶
func (c OnlyChildPseudoClassSelector) String() string
type PopoverPseudoClassSelector ¶
type PopoverPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (PopoverPseudoClassSelector) Match ¶
func (s PopoverPseudoClassSelector) Match(n *html.Node) bool
func (PopoverPseudoClassSelector) PseudoElement ¶
func (c PopoverPseudoClassSelector) PseudoElement() string
func (PopoverPseudoClassSelector) Specificity ¶
func (s PopoverPseudoClassSelector) Specificity() Specificity
func (PopoverPseudoClassSelector) String ¶
func (c PopoverPseudoClassSelector) String() string
type ReadOnlyPseudoClassSelector ¶
type ReadOnlyPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (ReadOnlyPseudoClassSelector) Match ¶
func (s ReadOnlyPseudoClassSelector) Match(n *html.Node) bool
func (ReadOnlyPseudoClassSelector) PseudoElement ¶
func (c ReadOnlyPseudoClassSelector) PseudoElement() string
func (ReadOnlyPseudoClassSelector) Specificity ¶
func (s ReadOnlyPseudoClassSelector) Specificity() Specificity
func (ReadOnlyPseudoClassSelector) String ¶
func (c ReadOnlyPseudoClassSelector) String() string
type RegexpPseudoClassSelector ¶
type RegexpPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (RegexpPseudoClassSelector) Match ¶
func (s RegexpPseudoClassSelector) Match(n *html.Node) bool
func (RegexpPseudoClassSelector) PseudoElement ¶
func (c RegexpPseudoClassSelector) PseudoElement() string
func (RegexpPseudoClassSelector) Specificity ¶
func (s RegexpPseudoClassSelector) Specificity() Specificity
func (RegexpPseudoClassSelector) String ¶
func (c RegexpPseudoClassSelector) String() string
type RelativePseudoClassSelector ¶
type RelativePseudoClassSelector struct {
// contains filtered or unexported fields
}
func (RelativePseudoClassSelector) Match ¶
func (s RelativePseudoClassSelector) Match(n *html.Node) bool
func (RelativePseudoClassSelector) PseudoElement ¶
func (c RelativePseudoClassSelector) PseudoElement() string
func (RelativePseudoClassSelector) Specificity ¶
func (s RelativePseudoClassSelector) Specificity() Specificity
Specificity returns the specificity of the most specific selectors in the pseudo-class arguments. See https://www.w3.org/TR/selectors/#specificity-rules
func (RelativePseudoClassSelector) String ¶
func (c RelativePseudoClassSelector) String() string
type RootPseudoClassSelector ¶
type RootPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (RootPseudoClassSelector) Match ¶
func (s RootPseudoClassSelector) Match(n *html.Node) bool
Match implements :root
func (RootPseudoClassSelector) PseudoElement ¶
func (c RootPseudoClassSelector) PseudoElement() string
func (RootPseudoClassSelector) Specificity ¶
func (s RootPseudoClassSelector) Specificity() Specificity
func (RootPseudoClassSelector) String ¶
func (c RootPseudoClassSelector) String() string
type Sel ¶
type Sel interface { Matcher Specificity() Specificity // Returns a CSS input compiling to this selector. String() string // Returns a pseudo-element, or an empty string. PseudoElement() string }
Sel is the interface for all the functionality provided by selectors.
func Parse ¶
Parse parses a selector. Use `ParseWithPseudoElement` if you need support for pseudo-elements.
func ParseWithPseudoElement ¶
ParseWithPseudoElement parses a single selector, with support for pseudo-element.
type SelectorGroup ¶
type SelectorGroup []Sel
A SelectorGroup is a list of selectors, which matches if any of the individual selectors matches.
func ParseGroup ¶
func ParseGroup(sel string) (SelectorGroup, error)
ParseGroup parses a selector, or a group of selectors separated by commas. Use `ParseGroupWithPseudoElements` if you need support for pseudo-elements.
func ParseGroupWithPseudoElements ¶
func ParseGroupWithPseudoElements(sel string) (SelectorGroup, error)
ParseGroupWithPseudoElements parses a selector, or a group of selectors separated by commas. It supports pseudo-elements.
func (SelectorGroup) Match ¶
func (s SelectorGroup) Match(n *html.Node) bool
Match returns true if the node matches one of the single selectors.
func (SelectorGroup) String ¶
func (c SelectorGroup) String() string
type Specificity ¶
type Specificity [3]int
Specificity is the CSS specificity as defined in https://www.w3.org/TR/selectors/#specificity-rules with the convention Specificity = [A,B,C].
func (Specificity) Add ¶
func (s Specificity) Add(other Specificity) Specificity
func (Specificity) Less ¶
func (s Specificity) Less(other Specificity) bool
returns `true` if s < other (strictly), false otherwise
type TagSelector ¶
type TagSelector struct {
// contains filtered or unexported fields
}
func (TagSelector) Match ¶
func (t TagSelector) Match(n *html.Node) bool
Matches elements with a given tag name.
func (TagSelector) PseudoElement ¶
func (c TagSelector) PseudoElement() string
func (TagSelector) Specificity ¶
func (c TagSelector) Specificity() Specificity
func (TagSelector) String ¶
func (c TagSelector) String() string
type TargetPseudoClassSelector ¶
type TargetPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (TargetPseudoClassSelector) Match ¶
func (s TargetPseudoClassSelector) Match(n *html.Node) bool
func (TargetPseudoClassSelector) PseudoElement ¶
func (c TargetPseudoClassSelector) PseudoElement() string
func (TargetPseudoClassSelector) Specificity ¶
func (s TargetPseudoClassSelector) Specificity() Specificity
func (TargetPseudoClassSelector) String ¶
func (c TargetPseudoClassSelector) String() string
type VisitedPseudoClassSelector ¶
type VisitedPseudoClassSelector struct {
// contains filtered or unexported fields
}
func (VisitedPseudoClassSelector) Match ¶
func (s VisitedPseudoClassSelector) Match(n *html.Node) bool
func (VisitedPseudoClassSelector) PseudoElement ¶
func (c VisitedPseudoClassSelector) PseudoElement() string
func (VisitedPseudoClassSelector) Specificity ¶
func (s VisitedPseudoClassSelector) Specificity() Specificity
func (VisitedPseudoClassSelector) String ¶
func (c VisitedPseudoClassSelector) String() string
type WherePseudoClassSelector ¶
type WherePseudoClassSelector struct {
// contains filtered or unexported fields
}
func (WherePseudoClassSelector) PseudoElement ¶
func (c WherePseudoClassSelector) PseudoElement() string
func (WherePseudoClassSelector) Selectors ¶
func (c WherePseudoClassSelector) Selectors() []Sel
func (WherePseudoClassSelector) Specificity ¶
func (s WherePseudoClassSelector) Specificity() Specificity
func (WherePseudoClassSelector) String ¶
func (c WherePseudoClassSelector) String() string