item

package
v2.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package item defines CSS items in the tree produced by a parser.

Index

Constants

View Source
const (
	TypeAtRule         = Type("at-rule")
	TypeQualifiedRule  = Type("qualified rule")
	TypeDeclaration    = Type("declaration")
	TypeComponentValue = Type("component value")
	TypePreservedToken = Type("preserved token")
	TypeFunction       = Type("function")
	TypeBlock          = Type("block")
)

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.

func (AtRule) String

func (i AtRule) String() string

func (AtRule) ToItem

func (i AtRule) ToItem() Item

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

func (Block) ToItem

func (i Block) ToItem() Item

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

func (Function) ToItem

func (i Function) ToItem() Item

type Item

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

An Item is a value in a tree produced by the parser.

func (Item) String

func (i Item) String() string

func (Item) ToAtRule

func (i Item) ToAtRule() AtRule

func (Item) ToBlock

func (i Item) ToBlock() Block

func (Item) ToComponentValue

func (i Item) ToComponentValue() ComponentValue

func (Item) ToDeclaration

func (i Item) ToDeclaration() Declaration

func (Item) ToFunction

func (i Item) ToFunction() Function

func (Item) ToPreservedToken

func (i Item) ToPreservedToken() PreservedToken

func (Item) ToQualifiedRule

func (i Item) ToQualifiedRule() QualifiedRule

type PreservedToken

type PreservedToken token.Token

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

type Type

type Type string

Jump to

Keyboard shortcuts

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