Wednesday, 28 November 2007 @ 10:42pm • life
CSSpool (pronounced "cesspool") is a validating SAC parser for CSS. The parser
calls methods on a document handler depending on what it has found. CSSPool
currently only supports CSS 2.1. CSSPool will not yield invalid properties or
selectors.
Changes:
## 0.2.0
Posted by Aaron Patterson •
Permalink •
Comments (0) •
Leave your Comment »
Saturday, 17 November 2007 @ 6:44pm • life
CSSpool (pronounced "cesspool") is a validating SAC parser for CSS. The parser
calls methods on a document handler depending on what it has found. CSSPool
currently only supports CSS 2.1. CSSPool will not yield invalid properties or
selectors.
Changes:
## 0.1.1
Posted by Aaron Patterson •
Permalink •
Comments (0) •
Leave your Comment »
Thursday, 15 November 2007 @ 1:08am • computadora, csspool
I just finished up a matching method on CSSPool. So you can pass an hpricot node to a selector AST, and determine whether the node matches or not.
Lets say for example that you had an html document and a css document, and you wanted to know what selectors matched a given hpricot node, you could do something like this:
class DH < CSS::SAC::DocumentHandler
def initialize(node)
@node = node
end
def start_selector(selectors)
selectors.each { |sel| p sel if sel =~ @node }
end
end
parser = CSS::SAC::Parser.new(DH.new(some_hpricot_node))
parser.parse(File.read(ARGV[0]))
I think I will probably release what I have in trunk soon. I will probably add a new document handler for 0.2.0 that collects all selectors and properties together, and give a nice interface for finding styles that apply to an hpricot node.
Posted by Aaron Patterson •
Permalink •
Comments (0) •
Leave your Comment »
Saturday, 3 November 2007 @ 11:36am • computadora
I forgot to mention. I am going to give a presentation at RejectConf tonight, and here are the slides.
See the CSSPool and Hpricot integration after the jump.
More...
Posted by Aaron Patterson •
Permalink •
Comments (3) •
Leave your Comment »
Saturday, 3 November 2007 @ 11:30am • computadora
I just released csspool version 0.1.0 last night, so I thought I'd write a little about it.
CSSPool is a CSS SAC parser. Basically it parses a CSS document calling methods on a document handler object. The parser will send the document handler lots of information about the CSS, like the selectors and properties. The selectors you get are ASTs, and implement .to_css methods so you can get back css.
Here is a quick example:
require 'css/sac/parser'
class SimpleDocHandler < CSS::SAC::DocumentHandler
def start_selector(selectors)
p selectors.map { |sel| sel.to_css }.join(', ')
end
def property(name, value, important)
puts "#{name}: #{value} #{important ? '!important' : ''}".strip
end
end
csspool = CSS::SAC::Parser.new(SimpleDocHandler.new)
csspool.parse(File.read(ARGV[0]))
Posted by Aaron Patterson •
Permalink •
Comments (0) •
Leave your Comment »