From 49604a3bae39e22507b5069fb4fba832c30ab032 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 20 Sep 2015 11:02:01 +0000 Subject: [PATCH] Table renders wrong if a trailing space is after | symbol (#18223). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Patch by Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@14611 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redcloth3.rb | 2 +- .../wiki_formatting/textile_formatter_test.rb | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/redcloth3.rb b/lib/redcloth3.rb index 0c44346d0..f9c9054b8 100644 --- a/lib/redcloth3.rb +++ b/lib/redcloth3.rb @@ -525,7 +525,7 @@ class RedCloth3 < String tatts = pba( tatts, 'table' ) tatts = shelve( tatts ) if tatts rows = [] - fullrow.gsub!(/([^|])\n/, "\\1
") + fullrow.gsub!(/([^|\s])\s*\n/, "\\1
") fullrow.each_line do |row| ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\. )(.*)/m cells = [] 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 6d816537e..65a91b20a 100644 --- a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb @@ -249,6 +249,28 @@ EXPECTED assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '') end + def test_table_with_trailing_whitespace + raw = <<-RAW +This is a table with trailing whitespace in one row: + +|cell11|cell12| +|cell21|cell22| +|cell31|cell32| +RAW + + expected = <<-EXPECTED +

This is a table with trailing whitespace in one row:

+ + + + + +
cell11cell12
cell21cell22
cell31cell32
+EXPECTED + + assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '') + end + def test_table_with_line_breaks raw = <<-RAW This is a table with line breaks: -- 2.39.5