Documentation ¶
Overview ¶
Package item defines CSS items in the tree produced by a parser.
Index ¶
- Constants
- type AtRule
- type Block
- type ComponentValue
- type Declaration
- type Function
- type Item
- func (i Item) String() string
- func (i Item) ToAtRule() AtRule
- func (i Item) ToBlock() Block
- func (i Item) ToComponentValue() ComponentValue
- func (i Item) ToDeclaration() Declaration
- func (i Item) ToFunction() Function
- func (i Item) ToPreservedToken() PreservedToken
- func (i Item) ToQualifiedRule() QualifiedRule
- type PreservedToken
- type QualifiedRule
- type Type
Constants ¶
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AtRule ¶
type AtRule struct { Name string Prelude []ComponentValue Block maybe.M[Block] }
AtRule describes an Item with a name, a prelude consisting of a list of component values, and an optional block consisting of a simple {} block.
type Block ¶
type Block struct { Delim token.Token Value []ComponentValue }
Block describes an Item that is a {}, (), [] block. It has a token that is either a <{-token>, <(-token>, or <[-token>, and a value consisting of a list of component values.
func (Block) ToComponentValue ¶
func (i Block) ToComponentValue() ComponentValue
type ComponentValue ¶
type ComponentValue struct {
// contains filtered or unexported fields
}
ComponentValue describes an Item that is either one of the preserved tokens, a function, or a simple block.
func (ComponentValue) IsPreservedToken ¶
func (i ComponentValue) IsPreservedToken(t token.Token) bool
IsPreservedToken returns true iff the component value is both of type PreservedToken and the preserved token is equal to the specified token.
func (ComponentValue) String ¶
func (i ComponentValue) String() string
func (ComponentValue) ToBlock ¶
func (i ComponentValue) ToBlock() Block
func (ComponentValue) ToFunction ¶
func (i ComponentValue) ToFunction() Function
func (ComponentValue) ToItem ¶
func (i ComponentValue) ToItem() Item
func (ComponentValue) ToPreservedToken ¶
func (i ComponentValue) ToPreservedToken() PreservedToken
type Declaration ¶
type Declaration struct { Name string Value []ComponentValue Important bool }
Declaration describes an Item that associates a property or descriptor name with a value. It has a name, a value consisting of a list of component values, and an important flag which is initially unset.
Declarations are further categorized as property declarations or descriptor declarations, with the former setting CSS properties and appearing most often in qualified rules and the latter setting CSS descriptors, which appear only in at-rules. However, this categorization does not occur at the Syntax level; instead, it is a product of where the declaration appears.
func (Declaration) ToItem ¶
func (i Declaration) ToItem() Item
type Function ¶
type Function struct { Name string Value []ComponentValue }
Function describes an Item with a name and a value consisting of a list of component values.
func (Function) ToComponentValue ¶
func (i Function) ToComponentValue() ComponentValue
type Item ¶
type Item struct {
// contains filtered or unexported fields
}
An Item is a value in a tree produced by the parser.
func (Item) ToComponentValue ¶
func (i Item) ToComponentValue() ComponentValue
func (Item) ToDeclaration ¶
func (i Item) ToDeclaration() Declaration
func (Item) ToFunction ¶
func (Item) ToPreservedToken ¶
func (i Item) ToPreservedToken() PreservedToken
func (Item) ToQualifiedRule ¶
func (i Item) ToQualifiedRule() QualifiedRule
type PreservedToken ¶
PreservedToken describes an Item that is any token produced by the tokenizer except for <function-token>, <{-token>, <(-token>, or <[-token>.
Note: The tokens <}-token>s, <)-token>s, <]-token>, <bad-string-token>, and <bad-url-token> are always parse errors, but they are preserved in the token stream by this specification to allow other specs, such as Media Queries, to define more fine-grained error-handling than just dropping an entire declaration or block.
func (PreservedToken) ToComponentValue ¶
func (i PreservedToken) ToComponentValue() ComponentValue
func (PreservedToken) ToItem ¶
func (i PreservedToken) ToItem() Item
type QualifiedRule ¶
type QualifiedRule struct { Prelude []ComponentValue Block Block }
QualifiedRule describes an Item with a prelude consisting of a list of component values, and a block consisting of a simple {} block.
Most qualified rules will be style rules, where the prelude is a selector and the block a list of declarations.
func (QualifiedRule) ToItem ¶
func (i QualifiedRule) ToItem() Item