Perfect!
doc.decorators(Nokogiri::XML::Element) << CSS::Element
doc.decorate!
describe "HtmlCssDecorator" do
it "works" do
doc = Nokogiri::HTML(File.open 'fixtures/test.html')
doc = CSS::Model.apply_to(doc, :css_path => File.dirname(__FILE__)
+ "/fixtures/")
doc.css('*').each do |elem|
puts show(elem) if elem.declarations
end
end
end
def show(elem)
s = ""
return s if !elem.declarations
elem.declarations.each do |decl|
s += decl[1].to_s
end
s
end
--
I now have access to precisely the CSS styles that would apply in the
browser for each HTML element.
The stylesheets referenced by the HTML doc are loaded, parsed and the
styles merged using the specificity calculations as given by W3C.
Sweet!!!
On May 1, 7:02 pm, Aaron Patterson <
aaron.patter...@gmail.com> wrote: