Documentation
¶
Index ¶
- func Match(selector Selector, node *uinode.Node) bool
- func MatchWithState(selector Selector, node *uinode.Node, state *State) bool
- func MatchWithStateAndContext(selector Selector, node *uinode.Node, state *State, ctx *MatchContext) bool
- func ScopeStylesheet(input, className string) (string, error)
- func SplitImportant(input string) (string, bool)
- func StripComments(input string) (string, error)
- type AttributeSelector
- type CompoundSelector
- type Declaration
- type Keyframe
- type Keyframes
- type MatchContext
- type PseudoClass
- type Rule
- type RuleCondition
- type RuleConditionKind
- type Selector
- type Specificity
- type State
- type Stylesheet
- type Token
- type TokenType
- type Tokenizer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ScopeStylesheet ¶
ScopeStylesheet parses CSS and adds className to each selector subject. The resulting stylesheet keeps media and container conditions intact.
func SplitImportant ¶
SplitImportant removes the terminal CSS !important flag while preserving the authored value. It only recognizes a flag outside a quoted/function token because strings such as content:"!important" are ordinary values.
func StripComments ¶
StripComments preserves quoted text and separates tokens around comments.
Types ¶
type AttributeSelector ¶
AttributeSelector matches an element that has the named content attribute.
type CompoundSelector ¶
type CompoundSelector struct {
Tag string
ID string
Classes []string
Attributes []AttributeSelector
PseudoClasses []PseudoClass
// contains filtered or unexported fields
}
func (CompoundSelector) String ¶
func (c CompoundSelector) String() string
type Declaration ¶
type Keyframe ¶
type Keyframe struct {
Offsets []float64
Declarations []Declaration
}
type Keyframes ¶
type Keyframes struct {
Name string
Frames []Keyframe
Conditions []RuleCondition
}
type MatchContext ¶
type MatchContext struct {
// contains filtered or unexported fields
}
func NewMatchContext ¶
func NewMatchContext() *MatchContext
func (*MatchContext) Reset ¶
func (c *MatchContext) Reset()
type PseudoClass ¶
type Rule ¶
type Rule struct {
Selectors []Selector
Declarations []Declaration
Conditions []RuleCondition
}
type RuleCondition ¶
type RuleCondition struct {
Prelude string
Kind RuleConditionKind
}
type RuleConditionKind ¶
type RuleConditionKind int
const ( RuleConditionMedia RuleConditionKind = iota RuleConditionContainer )
type Selector ¶
type Selector struct {
Parts []CompoundSelector
}
func (Selector) HasSiblingCombinator ¶
HasSiblingCombinator reports whether changing one branch can affect another.
type Specificity ¶
func CalculateSpecificity ¶
func CalculateSpecificity(selector Selector) Specificity
type Stylesheet ¶
func Parse ¶
func Parse(input string) (*Stylesheet, error)
func ParseParts ¶ added in v0.1.8
func ParseParts(parts ...string) (*Stylesheet, error)
ParseParts parses independent stylesheet sources in cascade order. Each source has its own token boundaries and appends directly to the result.
func (Stylesheet) String ¶
func (s Stylesheet) String() string
type Tokenizer ¶
type Tokenizer struct {
// contains filtered or unexported fields
}