Class: Flue::CodeFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/flue/content_filter.rb

Instance Method Summary collapse

Instance Method Details

#call(input, options = {}) ⇒ Object



65
66
67
68
69
70
71
72
# File 'lib/flue/content_filter.rb', line 65

def call(input, options={})
  doc = Nokogiri::HTML::DocumentFragment.parse(input)
  doc.css('code').each do |code|
    language = code["data-language"] || "ruby"
    code.replace(CodeRay.scan(code.content, language.to_sym).div)
  end
  doc.to_html
end