# GCI.unescape gives \<code\> tags generation

**URL:** <https://www.ruby-forum.com/t/gci-unescape-gives-code-tags-generation/232314>\
**Category:** Ruby\
**Created:** [October 2, 2014, 8:11am UTC](https://www.ruby-forum.com/t/gci-unescape-gives-code-tags-generation/232314 "2014-10-02T08:11:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [October 2, 2014, 8:11am UTC](https://www.ruby-forum.com/t/gci-unescape-gives-code-tags-generation/232314/1 "2014-10-02T08:11:35Z")

</div>

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(’  
’, “\n”)  
text = text.gsub(/\<_([A-Za-z0-9])_[\>]/, ‘’)  
text = text.gsub(’\>’, “\>”)  
text = text.gsub(’\<’, “\<”)  
text = text.gsub(’&nbsp;‘, " ")  
text = text.gsub(’&’, “&”)  
CodeRay.scan(text, lang).div(:css =\> :class)  
end  
end

Using the above gives:

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

Any other way of writing?:

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