def convert_codeblock(el, indent)
if el.attr['lang'] && HIGHLIGHTING_AVAILABLE
attr = el.attr.dup
opts = {:wrap => @options[:coderay_wrap], :line_numbers => @options[:coderay_line_numbers],
:line_number_start => @options[:coderay_line_number_start], :tab_width => @options[:coderay_tab_width],
:bold_every => @options[:coderay_bold_every], :css => @options[:coderay_css]}
result = CodeRay.scan(el.value, attr.delete('lang').to_sym).html(opts).chomp << "\n"
"#{' '*indent}<div#{html_attributes(attr)}>#{result}#{' '*indent}</div>\n"
else
result = escape_html(el.value)
result.chomp!
if el.attr['class'].to_s =~ /\bshow-whitespaces\b/
result.gsub!(/(?:(^[ \t]+)|([ \t]+$)|([ \t]+))/) do |m|
suffix = ($1 ? '-l' : ($2 ? '-r' : ''))
m.scan(/./).map do |c|
case c
when "\t" then "<span class=\"ws-tab#{suffix}\">\t</span>"
when " " then "<span class=\"ws-space#{suffix}\">⋅</span>"
end
end.join('')
end
end
"#{' '*indent}<pre#{html_attributes(el.attr)}><code>#{result}\n</code></pre>\n"
end
end