styles

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDictWriteSheet

func BuildDictWriteSheet(d *tokens.StringDict, node directives.Node) (string, error)

func BuildFile

func BuildFile(input string, outputPath string) error

func SaveMathFont added in v0.4.1

func SaveMathFont(dst string) error

func WriteSheetToFile

func WriteSheetToFile(s Sheet, path string) error

Types

type AtRule

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

func NewAtRule

func NewAtRule(sel *AtSelector, rules []Rule) *AtRule

func (*AtRule) ExpandNested

func (r *AtRule) ExpandNested() ([]Rule, error)

not called the first time. The subsequent times nothing should change

func (*AtRule) SetParent

func (r *AtRule) SetParent(parent *AtSelector)

func (*AtRule) Write

func (r *AtRule) Write(indent string, nl string, tab string) (string, error)

type AtRuleGen

type AtRuleGen func(sel Selector, key *tokens.String, attr *tokens.StringDict) ([]Rule, error)

type AtSelector

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

at rules can be endlessly deeply nested

func NewAtSelector

func NewAtSelector(key *tokens.String) *AtSelector

func (*AtSelector) Extend

func (s *AtSelector) Extend(extra *tokens.String) ([]Selector, error)

func (*AtSelector) Match

func (s *AtSelector) Match(tag tree.Tag) []tree.Tag

func (*AtSelector) SetParent

func (s *AtSelector) SetParent(parent *AtSelector)

func (*AtSelector) Write

func (s *AtSelector) Write() string

type AttrFilter

type AttrFilter interface {
	Match(attr *tokens.StringDict) bool
	Write() string
}

func ParseAttrFilter

func ParseAttrFilter(t_ raw.Token) (AttrFilter, error)

type AttrFilterData

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

type ContainsAttrFilter

type ContainsAttrFilter struct {
	AttrFilterData
}

func NewContainsAttrFilter

func NewContainsAttrFilter(name string, value string, ci bool) *ContainsAttrFilter

func (*ContainsAttrFilter) Match

func (f *ContainsAttrFilter) Match(attr *tokens.StringDict) bool

func (*ContainsAttrFilter) Write

func (f *ContainsAttrFilter) Write() string

type ExactAttrFilter

type ExactAttrFilter struct {
	AttrFilterData
}

func NewExactAttrFilter

func NewExactAttrFilter(name string, value string, ci bool) *ExactAttrFilter

value should be in quotes in the final code

func (*ExactAttrFilter) Match

func (f *ExactAttrFilter) Match(attr *tokens.StringDict) bool

func (*ExactAttrFilter) Write

func (f *ExactAttrFilter) Write() string

type FieldAttrFilter

type FieldAttrFilter struct {
	AttrFilterData
}

func NewFieldAttrFilter

func NewFieldAttrFilter(name string, value string, ci bool) *FieldAttrFilter

func (*FieldAttrFilter) Match

func (f *FieldAttrFilter) Match(attr *tokens.StringDict) bool

func (*FieldAttrFilter) Write

func (f *FieldAttrFilter) Write() string

type GenericPseudoClass

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

func NewGenericPseudoClass

func NewGenericPseudoClass(name string) *GenericPseudoClass

func NewGenericPseudoClassWithArgs

func NewGenericPseudoClassWithArgs(name string, args string) *GenericPseudoClass

func (*GenericPseudoClass) Write

func (p *GenericPseudoClass) Write() string

type PlainAttrFilter

type PlainAttrFilter struct {
	AttrFilterData
}

func NewPlainAttrFilter

func NewPlainAttrFilter(name string) *PlainAttrFilter

func (*PlainAttrFilter) Match

func (f *PlainAttrFilter) Match(attr *tokens.StringDict) bool

func (*PlainAttrFilter) Write

func (f *PlainAttrFilter) Write() string

type PrefixAttrFilter

type PrefixAttrFilter struct {
	AttrFilterData
}

func NewPrefixAttrFilter

func NewPrefixAttrFilter(name string, value string, ci bool) *PrefixAttrFilter

func (*PrefixAttrFilter) Match

func (f *PrefixAttrFilter) Match(attr *tokens.StringDict) bool

func (*PrefixAttrFilter) Write

func (f *PrefixAttrFilter) Write() string

type PseudoClass

type PseudoClass interface {
	Write() string
}

func ParsePseudoClass

func ParsePseudoClass(ts []raw.Token) (PseudoClass, error)

type Rule

type Rule interface {
	ExpandNested() ([]Rule, error) // includes self as first
	//ExpandLazy(root *tree.Root) ([]Rule, error) // modifies the root!, adding rules, but keeping all the originals untouched, any remaining lazy values are ignored in the core rule output
	Write(indent string, nl string, tab string) (string, error)
}

func ExpandAtRules

func ExpandAtRules(sel Selector, key *tokens.String, attr *tokens.StringDict) ([]Rule, error)

sel == nil is toplevel at rule

func NewMediaRule

func NewMediaRule(sel Selector, key *tokens.String, attr *tokens.StringDict) ([]Rule, error)

func NewPageRule

func NewPageRule(sel Selector, key *tokens.String, attr *tokens.StringDict) ([]Rule, error)

func NewSupportsRule

func NewSupportsRule(sel Selector, key *tokens.String, attr *tokens.StringDict) ([]Rule, error)

func NewWrapRule

func NewWrapRule(sel Selector, key *tokens.String, attr *tokens.StringDict) ([]Rule, error)

func NewWrapSiblingsRule

func NewWrapSiblingsRule(sel Selector, key *tokens.String, attr *tokens.StringDict) ([]Rule, error)

type RuleData

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

func NewRule

func NewRule(sel Selector, attr *tokens.StringDict) *RuleData

func (*RuleData) ExpandNested

func (r *RuleData) ExpandNested() ([]Rule, error)

func (*RuleData) IsLazy

func (r *RuleData) IsLazy() bool

func (*RuleData) Write

func (r *RuleData) Write(indent string, nl string, tab string) (string, error)

type Selector

type Selector interface {
	Extend(extra *tokens.String) ([]Selector, error) // eg. pseudo selector, or child
	Match(tag tree.Tag) []tree.Tag                   // returns empty list if no match
	Write() string
}

func ParseSelectorList

func ParseSelectorList(query *tokens.String) ([]Selector, error)

type SelectorData

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

func ParseSelector

func ParseSelector(ts []raw.Token) (*SelectorData, error)

func (*SelectorData) Copy

func (s *SelectorData) Copy() *SelectorData

func (*SelectorData) Extend

func (s *SelectorData) Extend(extra *tokens.String) ([]Selector, error)

func (*SelectorData) Match

func (s *SelectorData) Match(tag tree.Tag) []tree.Tag

func (*SelectorData) Write

func (s *SelectorData) Write() string

type Sheet

type Sheet interface {
	Append(r Rule)
	IsEmpty() bool
	Len() int
	//IsNotLazy() bool
	Write(compr bool, nl string, tab string) (string, error)
	ExpandNested() (Sheet, error) // expanding a second time does nothing
	ApplyExtensions(root *tree.Root) (*tree.Root, error)
}

func Build

func Build(path string, ctx context.Context) (Sheet, error)

expects export var style = {...} somewhere in file

func BuildDict

func BuildDict(d *tokens.StringDict) (Sheet, error)

func NewSheet

func NewSheet() Sheet

type SheetData

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

func (*SheetData) Append

func (s *SheetData) Append(r Rule)

func (*SheetData) ApplyExtensions

func (s *SheetData) ApplyExtensions(root *tree.Root) (*tree.Root, error)

func (*SheetData) ExpandNested

func (s *SheetData) ExpandNested() (Sheet, error)

func (*SheetData) IsEmpty

func (s *SheetData) IsEmpty() bool

func (*SheetData) Len

func (s *SheetData) Len() int

func (*SheetData) Write

func (s *SheetData) Write(compr bool, nl string, tab string) (string, error)

type SubcodeAttrFilter

type SubcodeAttrFilter struct {
	AttrFilterData
}

func NewSubcodeAttrFilter

func NewSubcodeAttrFilter(name string, value string, ci bool) *SubcodeAttrFilter

func (*SubcodeAttrFilter) Match

func (f *SubcodeAttrFilter) Match(attr *tokens.StringDict) bool

func (*SubcodeAttrFilter) Write

func (f *SubcodeAttrFilter) Write() string

type SuffixAttrFilter

type SuffixAttrFilter struct {
	AttrFilterData
}

func NewSuffixAttrFilter

func NewSuffixAttrFilter(name string, value string, ci bool) *SuffixAttrFilter

func (*SuffixAttrFilter) Match

func (f *SuffixAttrFilter) Match(attr *tokens.StringDict) bool

func (*SuffixAttrFilter) Write

func (f *SuffixAttrFilter) Write() string

type WrapRule

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

@wrap and @wrap-siblings are special at-rules that insert <div id=... class=.....> tags into the tree they do this before the other rules are evaluated TODO: as js query to combine with cross-lang template import in js, must be runtime because we don't know where template might be injected, all wrap statements must be executed? only @wrap can have runtime js equivalent, @wrap-siblings not

func (*WrapRule) ApplyWrap

func (r *WrapRule) ApplyWrap(tag tree.Tag) error

func (*WrapRule) ExpandNested

func (r *WrapRule) ExpandNested() ([]Rule, error)

func (*WrapRule) Write

func (r *WrapRule) Write(indent string, nl string, tab string) (string, error)

Jump to

Keyboard shortcuts

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