]> source.dussan.org Git - redmine.git/commitdiff
Table renders wrong if a trailing space is after | symbol (#18223).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 20 Sep 2015 11:02:01 +0000 (11:02 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 20 Sep 2015 11:02:01 +0000 (11:02 +0000)
Patch by Jens Krämer.

git-svn-id: http://svn.redmine.org/redmine/trunk@14611 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redcloth3.rb
test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb

index 0c44346d0a60c199af9f7b65f1cf0215cf67dd1f..f9c9054b87e62c0f7b59729776cef9392e365459 100644 (file)
@@ -525,7 +525,7 @@ class RedCloth3 < String
             tatts = pba( tatts, 'table' )
             tatts = shelve( tatts ) if tatts
             rows = []
-            fullrow.gsub!(/([^|])\n/, "\\1<br />")
+            fullrow.gsub!(/([^|\s])\s*\n/, "\\1<br />")
             fullrow.each_line do |row|
                 ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\. )(.*)/m
                 cells = []
index 6d816537e5c6bcdb9c7496db249fa7276831e014..65a91b20ac8b2523fa0cf54f557e92cb4f863d80 100644 (file)
@@ -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
+<p>This is a table with trailing whitespace in one row:</p>
+
+<table>
+  <tr><td>cell11</td><td>cell12</td></tr>
+  <tr><td>cell21</td><td>cell22</td></tr>
+  <tr><td>cell31</td><td>cell32</td></tr>
+</table>
+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: