# File lib/gerbil/html.rb, line 56 def thru_redcloth text = dup # redcloth does not correctly convert -- into — text.gsub! %r{\b--\b}, '—' html = RedCloth.new(text).to_html # redcloth adds <span> tags around acronyms html.gsub! %r{<span class="caps">([[:upper:][:digit:]]+)</span>}, '\1' # redcloth wraps indented text within <pre><code> tags html.gsub! %r{(<pre>)\s*<code>(.*?)\s*</code>\s*(</pre>)}m, '\1\2\3' # redcloth wraps a single item within paragraph tags, which # prevents the item's HTML from being validly injected within # other block-level elements, such as headings (h1, h2, etc.) html.sub! %r{^<p>(.*)</p>$}m do |match| payload = $1 if payload =~ /<p>/ match else payload end end html end