lib/trainbbcode.rb in trainbbcode-0.3.2 vs lib/trainbbcode.rb in trainbbcode-0.3.3

- old
+ new

@@ -155,13 +155,16 @@ s=s.gsub(/<br \/><(ul|li|table|tr|td|th)/,'<\1') s=s.gsub(/<br \/><\/(ul|li|table|tr|td|th)/,'</\1') end def coderay(s) scan=s.scan(/\[code lang=(.+?)\](.+?)\[\/code\]/m) - parse=scan[0][1].gsub("&lt;","<").gsub("&gt;",">") - lang=scan[0][0] - "[nobbc]" + CodeRay.scan(parse, lang).div(:css => :class, :line_numbers => @config[:syntax_highlighting_line_numbers]) + "[/nobbc]" + scan.each do |a| + parse=a[1].gsub("&lt;","<").gsub("&gt;",">") + lang=a[0] + s=s.gsub(/\[code lang=.+?\]#{a[1]}\[\/code\]/m,"[nobbc]" + CodeRay.scan(parse, lang).div(:css => :class, :line_numbers => @config[:syntax_highlighting_line_numbers]) + "[/nobbc]") + end + s end end #Add .tbbc to Strings class String @@ -169,5 +172,8 @@ bbc=TBBC.new bbc.conf(conf) if conf bbc.parse(self) end end + +t=TBBC.new +puts t.parse("[code lang=ruby]def test\nputs \"MMMMMMMUlti Line\"\nend[/code]\nThis is a bit more text\n[code lang=ruby]a=\"TESTING\"[/code]")