Project

General

Profile

Defect #7846 ยป textile_header_with_backslash_and_digit.patch

Etienne Massip, 2011-03-12 18:16

View differences:

lib/redcloth3.rb (working copy)
707 707
            atts = pba( atts )
708 708

  
709 709
            # pass to prefix handler
710
            replacement = nil
710 711
            if respond_to? "textile_#{ tag }", true
711
                text.gsub!( $&, method( "textile_#{ tag }" ).call( tag, atts, cite, content ) )
712
              replacement = method( "textile_#{ tag }" ).call( tag, atts, cite, content )
712 713
            elsif respond_to? "textile_#{ tagpre }_", true
713
                text.gsub!( $&, method( "textile_#{ tagpre }_" ).call( tagpre, num, atts, cite, content ) )
714
              replacement = method( "textile_#{ tagpre }_" ).call( tagpre, num, atts, cite, content )  
714 715
            end
716
            text.gsub!( $& ) { replacement } if replacement
715 717
        end
716 718
    end
717 719
    
test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb (working copy)
64 64
      '@<Location /redmine>@'    => '<code>&lt;Location /redmine&gt;</code>'
65 65
    )
66 66
  end
67
  
67

  
68 68
  def test_escaping
69 69
    assert_html_output(
70 70
      'this is a <script>'      => 'this is a &lt;script&gt;'
71 71
    )
72 72
  end
73

  
74
  def test_use_of_backslashes_followed_by_numbers_in_headers
75
    assert_html_output({
76
      'h1. 2009\02\09'      => '<h1>2009\02\09</h1>'
77
    }, false)
78
  end
73 79
  
74 80
  def test_double_dashes_should_not_strikethrough
75 81
    assert_html_output(
......
88 94
  
89 95
  private
90 96
  
91
  def assert_html_output(to_test)
97
  def assert_html_output(to_test, expect_paragraph = true)
92 98
    to_test.each do |text, expected|
93
      assert_equal "<p>#{expected}</p>", @formatter.new(text).to_html, "Formatting the following text failed:\n===\n#{text}\n===\n"
99
      assert_equal ( expect_paragraph ? "<p>#{expected}</p>" : expected ), @formatter.new(text).to_html, "Formatting the following text failed:\n===\n#{text}\n===\n"
94 100
    end
95 101
  end
96 102
end
    (1-1/1)