]> source.dussan.org Git - redmine.git/commitdiff
Fixed that ordered/unordered lists inside table cell are mangled (#14038).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 14 May 2013 16:29:59 +0000 (16:29 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 14 May 2013 16:29:59 +0000 (16:29 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11845 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 0d6ca324c3143fa3c6b19788072e0b05496dbcf7..dbab20750a072416c522867f1b96b6f59b6485bb 100644 (file)
@@ -525,11 +525,12 @@ class RedCloth3 < String
             tatts = pba( tatts, 'table' )
             tatts = shelve( tatts ) if tatts
             rows = []
-
+            fullrow.gsub!(/([^|])\n/, "\\1<br />")
             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 =~ /^_/
index 69c697daac19af1f09c9de4a4d58d7bdf8d5b005..324cea1e6f01264c8db1feedd40f1ff0e33eefb6 100644 (file)
@@ -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
+<p>This is a table with lists:</p>
+
+<table>
+  <tr>
+    <td>cell11</td>
+    <td>cell12</td>
+  </tr>
+  <tr>
+    <td>cell21</td>
+    <td>ordered list<br /># item<br /># item 2</td>
+  </tr>
+  <tr>
+    <td>cell31</td>
+    <td>unordered list<br />* item<br />* item 2</td>
+  </tr>
+</table>
+EXPECTED
+
+    assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '')
+  end
+
   def test_textile_should_not_mangle_brackets
     assert_equal '<p>[msg1][msg2]</p>', to_html('[msg1][msg2]')
   end