Method: MaRuKu::Out::HTML#uv_highlight

Defined in:
lib/ramaze/contrib/maruku_uv.rb

#uv_highlight(source, lang, style) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ramaze/contrib/maruku_uv.rb', line 13

def uv_highlight(source, lang, style)
  require 'uv'

  html = Uv.parse(source, 'xhtml', lang, lines = false, style)

  # Prepare <code> containing <pre>
  code = Document.new(html, :respect_whitespace => :all).root
  code.name = 'code'
  code.attributes['class'] = lang
  code.attributes['lang'] = lang

  # Prepare <pre>
  pre = Element.new('pre')
  pre << code
  pre.attributes['class'] = style
  pre
rescue => ex
  puts ex
  to_html_code_using_pre(source)
end