css

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Match

func Match(selector Selector, node *dom.Node) bool

func MatchWithState

func MatchWithState(selector Selector, node *dom.Node, state *State) bool

func MatchWithStateAndContext

func MatchWithStateAndContext(selector Selector, node *dom.Node, state *State, ctx *MatchContext) bool

func ScopeStylesheet

func ScopeStylesheet(input, className string) (string, error)

ScopeStylesheet parses CSS and adds className to each selector subject. The resulting stylesheet keeps media and container conditions intact.

func SplitImportant

func SplitImportant(input string) (string, bool)

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

func StripComments(input string) (string, error)

StripComments preserves quoted text and separates tokens around comments.

Types

type AttributeSelector

type AttributeSelector struct {
	Name            string
	Operator        string
	Value           string
	CaseInsensitive bool
}

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 Declaration struct {
	Property  string
	Value     string
	Important bool
}

type Keyframe

type Keyframe struct {
	Offsets      []float64
	Declarations []Declaration
}

type Keyframes

type Keyframes struct {
	Name       string
	Frames     []Keyframe
	Conditions []RuleCondition
}

func (Keyframes) String

func (k Keyframes) String() string

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 PseudoClass struct {
	Name      string
	Value     string
	Selectors []Selector
	// contains filtered or unexported fields
}

type Rule

type Rule struct {
	Selectors    []Selector
	Declarations []Declaration
	Conditions   []RuleCondition
}

func (Rule) String

func (r Rule) String() string

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

func (s Selector) HasSiblingCombinator() bool

HasSiblingCombinator reports whether changing one branch can affect another.

func (Selector) String

func (s Selector) String() string

type Specificity

type Specificity struct {
	ID    int
	Class int
	Tag   int
}

func CalculateSpecificity

func CalculateSpecificity(selector Selector) Specificity

type State

type State struct {
	Focused      *dom.Node
	Hovered      *dom.Node
	Active       *dom.Node
	FocusVisible bool
}

type Stylesheet

type Stylesheet struct {
	Rules     []Rule
	Keyframes []Keyframes
}

func Parse

func Parse(input string) (*Stylesheet, error)

func (Stylesheet) String

func (s Stylesheet) String() string

type Token

type Token struct {
	Value string
	Type  TokenType
}

type TokenType

type TokenType int
const (
	TokenEOF TokenType = iota
	TokenWhitespace
	TokenIdent
	TokenHash
	TokenDot
	TokenLBrace
	TokenRBrace
	TokenColon
	TokenSemicolon
	TokenComma
	TokenAtKeyword
	TokenLBracket
	TokenRBracket
	TokenString
	TokenDelim
)

type Tokenizer

type Tokenizer struct {
	// contains filtered or unexported fields
}

func NewTokenizer

func NewTokenizer(input string) *Tokenizer

func (*Tokenizer) Next

func (t *Tokenizer) Next() (Token, error)

func (*Tokenizer) Peek

func (t *Tokenizer) Peek() (Token, error)

func (*Tokenizer) ReadDeclarationValue

func (t *Tokenizer) ReadDeclarationValue() string

Jump to

Keyboard shortcuts

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