Class: HiLite::CssEmbedder

Inherits:
Object
  • Object
show all
Defined in:
lib/hi-lite/css_embedder.rb

Class Method Summary collapse

Class Method Details

.embed(code, css) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/hi-lite/css_embedder.rb', line 7

def embed(code, css)
  code = Nokogiri::HTML.fragment(code)
  css.each_selector do |selector, style|
    code.css(selector).each do |node|
      node["style"] = ((node["style"] || "").split(";") + style.split(";")).join(";")
    end
  end
  remove_class(code)
  code.to_s
end