From b3d80d50a3a1f8bdf7ada546898ecb1818947b05 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 14 May 2013 16:29:59 +0000 Subject: [PATCH] Fixed that ordered/unordered lists inside table cell are mangled (#14038). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11845 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redcloth3.rb | 3 +- .../wiki_formatting/textile_formatter_test.rb | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/lib/redcloth3.rb b/lib/redcloth3.rb index 0d6ca324c..dbab20750 100644 --- a/lib/redcloth3.rb +++ b/lib/redcloth3.rb @@ -525,11 +525,12 @@ class RedCloth3 < String tatts = pba( tatts, 'table' ) tatts = shelve( tatts ) if tatts rows = [] - + fullrow.gsub!(/([^|])\n/, "\\1
") fullrow.each_line do |row| ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\. )(.*)/m cells = [] row.split( /(\|)(?![^\[\|]*\]\])/ )[1..-2].each do |cell| + Rails.logger.debug "cell: #{cell}" next if cell == '|' ctyp = 'd' ctyp = 'h' if cell =~ /^_/ diff --git a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb index 69c697daa..324cea1e6 100644 --- a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb @@ -268,6 +268,42 @@ EXPECTED assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '') end + def test_tables_with_lists + raw = <<-RAW +This is a table with lists: + +|cell11|cell12| +|cell21|ordered list +# item +# item 2| +|cell31|unordered list +* item +* item 2| + +RAW + + expected = <<-EXPECTED +

This is a table with lists:

+ + + + + + + + + + + + + + +
cell11cell12
cell21ordered list
# item
# item 2
cell31unordered list
* item
* item 2
+EXPECTED + + assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '') + end + def test_textile_should_not_mangle_brackets assert_equal '

[msg1][msg2]

', to_html('[msg1][msg2]') end