1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

in textile extensions, simplify regexp literal, and remove spurious extra newline in code blocks

This commit is contained in:
Xavier Noria 2009-02-28 14:26:30 +01:00
parent da5549b83f
commit 5257ea7f44

View file

@ -31,10 +31,10 @@ module RailsGuides
end end
def code(body) def code(body)
body.gsub!(/\<(yaml|shell|ruby|erb|html|sql)\>(.*?)\<\/\1\>/m) do |m| body.gsub!(%r{<(yaml|shell|ruby|erb|html|sql)>(.*?)</\1>}m) do |m|
es = ERB::Util.h($2) es = ERB::Util.h($2)
css_class = ['erb', 'shell'].include?($1) ? 'html' : $1 css_class = ['erb', 'shell'].include?($1) ? 'html' : $1
%{<notextile><div class="code_container"><code class="#{css_class}">#{es}\n</code></div></notextile>} %{<notextile><div class="code_container"><code class="#{css_class}">#{es}</code></div></notextile>}
end end
end end
end end