Project

General

Profile

Feature #2985 » redcloth.diff

Jean-Baptiste Barth, 2009-03-16 17:38

View differences:

test/unit/helpers/application_helper_test.rb (working copy)
50 50
      '(see "inline link":http://www.foo.bar/Test)' => '(see <a href="http://www.foo.bar/Test" class="external">inline link</a>)',
51 51
      '(see "inline link":http://www.foo.bar/Test).' => '(see <a href="http://www.foo.bar/Test" class="external">inline link</a>).',
52 52
      'www.foo.bar' => '<a class="external" href="http://www.foo.bar">www.foo.bar</a>',
53
      'http://foo.bar/page?p=1&t=z&s=' => '<a class="external" href="http://foo.bar/page?p=1&#38;t=z&#38;s=">http://foo.bar/page?p=1&#38;t=z&#38;s=</a>',
53
      'http://foo.bar/page?p=1&t=z&s=' => '<a class="external" href="http://foo.bar/page?p=1&t=z&s=">http://foo.bar/page?p=1&t=z&s=</a>',
54 54
      'http://foo.bar/page#125' => '<a class="external" href="http://foo.bar/page#125">http://foo.bar/page#125</a>',
55 55
      'http://foo@www.bar.com' => '<a class="external" href="http://foo@www.bar.com">http://foo@www.bar.com</a>',
56 56
      'http://foo:bar@www.bar.com' => '<a class="external" href="http://foo:bar@www.bar.com">http://foo:bar@www.bar.com</a>',
lib/redcloth3.rb (working copy)
309 309
        retrieve text
310 310

  
311 311
        text.gsub!( /<\/?notextile>/, '' )
312
        text.gsub!( /x%x%/, '&#38;' )
312
        ### Disabled as it just bugs in pre/code blocks!!
313
        #text.gsub!( /x%x%/, '&#38;' )
313 314
        clean_html text if filter_html
314 315
        text.strip!
315 316
        text
......
968 969
        ## turn any incoming ampersands into a dummy character for now.
969 970
        ## This uses a negative lookahead for alphanumerics followed by a semicolon,
970 971
        ## implying an incoming html entity, to be skipped
971

  
972
        text.gsub!( /&(?![#a-z0-9]+;)/i, "x%x%" )
972
        
973
        ### Disabled as it just bugs in pre/code blocks
974
        ### try: blah.map(&:test) in a code block...
975
        #text.gsub!( /&(?![#a-z0-9]+;)/i, "x%x%" )
973 976
    end
974 977

  
975 978
    def no_textile( text ) 
......
1050 1053
            codepre, used_offtags = 0, {}
1051 1054
            text.gsub!( OFFTAG_MATCH ) do |line|
1052 1055
                if $3
1053
                    offtag, aftertag = $4, $5
1056
                    first, offtag, aftertag = $3, $4, $5
1054 1057
                    codepre += 1
1055 1058
                    used_offtags[offtag] = true
1056 1059
                    if codepre - used_offtags.length > 0
......
1058 1061
                        @pre_list.last << line
1059 1062
                        line = ""
1060 1063
                    else
1061
                        htmlesc( aftertag, :NoQuotes ) if aftertag
1064
                        ### htmlesc is disabled between CODE tags which will be parsed with highlighter
1065
                        ### Regexp in formatter.rb is : /<code\s+class="(\w+)">\s?(.+)/m
1066
                        ### NB: some changes were made not to use $N variables, because we use "match" 
1067
                        ###   and it breaks following lines
1068
                        htmlesc( aftertag, :NoQuotes ) if (aftertag && !first.match(/<code\s+class="(\w+)">/))
1062 1069
                        line = "<redpre##{ @pre_list.length }>"
1063
                        $3.match(/<#{ OFFTAGS }([^>]*)>/)
1070
                        first.match(/<#{ OFFTAGS }([^>]*)>/)
1064 1071
                        tag = $1
1065 1072
                        $2.to_s.match(/(class\=\S+)/i)
1066 1073
                        tag << " #{$1}" if $1
(2-2/4)