# File lib/erbook/html.rb, line 80 def thru_coderay gsub %r{<(code)(.*?)>(.*?)</\1>}m do atts, code = $2, CGI.unescapeHTML($3) lang = atts[/\blang=('|")(.*?)\1/i, 2] || :ruby html = CodeRay.scan(code, lang).html(:css => :style) tag = if code =~ /\n/ then :pre else :code end %{<#{tag} class="code"#{atts}>#{html}</#{tag}>} end end