Skip to content

mnoble/csstree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSSTree

Ultra-simple CSS parser.

Install

gem install csstree

Usage

Parsing CSS

tree = CSSTree.parse("body { background-color: #FFFFFF; color: #000000; }")
# => #<CSSTree:0x123456>

Finding Rules For A Selector

tree.find("body")
# => #<OpenStruct background_color="#FFFFFF" color="#000000">

Access Properties

tree.find("body").color
# => "#000000"

Access Dashed Property Names Using Underscores

tree.find("body").background_color
# => "#FFFFFF"

Manipulating the Tree

tree.find("body").color = "#A3A3A3"
# => "#A3A3A3"

Rendering Normal CSS

tree.render
# => "body { background-color: #FFFFFF; color: #A3A3A3; }

About

Ultra-simple css parser.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages