Sylar
Sylar

Reputation: 12092

GCI.unescape gives <code> tags generation

def coderay(text)
 text.gsub(/\<pre( )?\="" lang="(.+?)">\<code( )?\="" lang="(.+?)">(.+?)\<\/code\>\<\/pre\>/m) do
  lang = $4
  text = CGI.unescapeHTML($5).gsub /\<code( )?\="" lang="(.+?)">|\<\/code\>/, ""
  text = text.gsub('<br />', "\n")
  text = text.gsub(/[\<]([\/])*([A-Za-z0-9])*[\>]/, '')
  text = text.gsub('>', ">")
  text = text.gsub('<', "<")
  text = text.gsub('&#160;', " ")
  text = text.gsub('&', "&")
  CodeRay.scan(text, lang).div(:css => :class)
 end
end

The above generates this at the last closing "end":

</code(></code(></pre(>

Anyone knows why? I am using gems CodeRay 1.1.0 and RedCloth 4.2.9. Ruby version: 2.1.1 and Rails 3.2.19. RefineryCMS 2.1.3 and their blog engine.

I thought that this line was the cure but it is not:

text = CGI.unescapeHTML($5).gsub /\<code( )?\="" lang="(.+?)">|\<\/code\>/, ""

Edited:

This is in the show.html.erb file:

<%= raw (coderay(RedCloth.new(render 'post').to_html)) %>

Upvotes: 0

Views: 61

Answers (0)

Related Questions