Documentation
¶
Overview ¶
Package css is for parsing css stylesheet.
import (
"github.com/vanng822/css"
"fmt"
)
func main() {
csstext = "td {width: 100px; height: 100px;}"
ss := css.Parse(csstext)
rules := ss.GetCSSRuleList()
for _, rule := range rules {
fmt.Println(rule.Style.SelectorText)
fmt.Println(rule.Style.Styles)
}
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseBlock ¶
func ParseBlock(csstext string) map[string]*CSSStyleDeclaration
ParseBlock take a string of a css block, parses it and returns a map of css style declarations.
Types ¶
type CSSRule ¶
type CSSRule struct {
Type RuleType
Style CSSStyleRule
Rules []*CSSRule
}
type CSSStyleDeclaration ¶
func NewCSSStyleDeclaration ¶
func NewCSSStyleDeclaration(property, value string, important int) *CSSStyleDeclaration
func (*CSSStyleDeclaration) Text ¶
func (decl *CSSStyleDeclaration) Text() string
type CSSStyleRule ¶
type CSSStyleRule struct {
SelectorText string
Styles map[string]*CSSStyleDeclaration
}
func (*CSSStyleRule) Text ¶
func (sr *CSSStyleRule) Text() string
type CSSStyleSheet ¶
func Parse ¶
func Parse(csstext string) *CSSStyleSheet
Parse takes a string of valid css rules, stylesheet, and parses it. Be aware this function has poor error handling so you should have valid syntax in your css
func (*CSSStyleSheet) GetCSSRuleList ¶
func (ss *CSSStyleSheet) GetCSSRuleList() []*CSSRule
Click to show internal directories.
Click to hide internal directories.