OSDN Git Service

Do not html escape code that is going to be highlighted (#2985, #3359).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 14 Mar 2010 09:05:58 +0000 (09:05 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 14 Mar 2010 09:05:58 +0000 (09:05 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3582 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redcloth3.rb
lib/redmine/wiki_formatting/textile/formatter.rb

index 2470fa5..fb96916 100644 (file)
@@ -1060,7 +1060,7 @@ class RedCloth3 < String
             codepre, used_offtags = 0, {}
             text.gsub!( OFFTAG_MATCH ) do |line|
                 if $3
-                    offtag, aftertag = $4, $5
+                    first, offtag, aftertag = $3, $4, $5
                     codepre += 1
                     used_offtags[offtag] = true
                     if codepre - used_offtags.length > 0
@@ -1068,9 +1068,13 @@ class RedCloth3 < String
                         @pre_list.last << line
                         line = ""
                     else
-                        htmlesc( aftertag, :NoQuotes ) if aftertag && escape_aftertag
+                        ### htmlesc is disabled between CODE tags which will be parsed with highlighter
+                        ### Regexp in formatter.rb is : /<code\s+class="(\w+)">\s?(.+)/m
+                        ### NB: some changes were made not to use $N variables, because we use "match"
+                        ###   and it breaks following lines
+                        htmlesc( aftertag, :NoQuotes ) if aftertag && escape_aftertag && !first.match(/<code\s+class="(\w+)">/)
                         line = "<redpre##{ @pre_list.length }>"
-                        $3.match(/<#{ OFFTAGS }([^>]*)>/)
+                        first.match(/<#{ OFFTAGS }([^>]*)>/)
                         tag = $1
                         $2.to_s.match(/(class\=\S+)/i)
                         tag << " #{$1}" if $1
index ab66ba5..2010986 100644 (file)
@@ -54,7 +54,7 @@ module Redmine
               content = @pre_list[$1.to_i]
               if content.match(/<code\s+class="(\w+)">\s?(.+)/m)
                 content = "<code class=\"#{$1} CodeRay\">" + 
-                  CodeRay.scan($2, $1.downcase).html(:escape => false, :line_numbers => :inline)
+                  CodeRay.scan($2, $1.downcase).html(:line_numbers => :inline)
               end
               content
             end