Class: Rack::SyntaxHighlighter

Inherits:
Plastic
  • Object
show all
Defined in:
lib/rack-syntax-highlighter.rb

Instance Method Summary collapse

Instance Method Details

#change_nokogiri_doc(doc) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/rack-syntax-highlighter.rb', line 6

def change_nokogiri_doc(doc)
  doc.search("//pre/code[@class]").each do |code|
    highlighted = Nokogiri.parse(
      Albino.colorize(code.text.rstrip, code[:class])).
      search("//div/pre").inner_html
    code.replace(%Q{<code class="highlighted">#{highlighted}</code>})
  end
  doc
end