]> source.dussan.org Git - redmine.git/commitdiff
Fixed that textile nested lists are not properly closed in output (#10642).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 18 Apr 2012 12:00:54 +0000 (12:00 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 18 Apr 2012 12:00:54 +0000 (12:00 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9430 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index f6333b3febf5d66e9b94972630de3134e59fc5f2..c91c61718a2a8e292e1669d80b96206127f41e28 100644 (file)
@@ -585,7 +585,7 @@ class RedCloth3 < String
                     last_line = line_id
                 end
                 if line_id - last_line > 1 or line_id == lines.length - 1
-                    depth.delete_if do |v|
+                    while v = depth.pop
                         lines[last_line] << "</li>\n\t</#{ lT( v ) }l>"
                     end
                 end
index 4253b71529a20aacec4230043e296f4b55de1ee3..548a378b56ee129a2704360c2e9482cad5434df4 100644 (file)
@@ -110,6 +110,36 @@ class Redmine::WikiFormatting::TextileFormatterTest < ActionView::TestCase
     )
   end
 
+  def test_nested_lists
+    raw = <<-RAW
+# Item 1
+# Item 2
+** Item 2a
+** Item 2b
+# Item 3
+** Item 3a
+RAW
+
+    expected = <<-EXPECTED
+<ol>
+  <li>Item 1</li>
+  <li>Item 2
+    <ul>
+      <li>Item 2a</li>
+      <li>Item 2b</li>
+    </ul>
+  </li>
+  <li>Item 3
+    <ul>
+      <li>Item 3a</li>
+    </ul>
+  </li>
+</ol>
+EXPECTED
+
+    assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '')
+  end
+
   def test_escaping
     assert_html_output(
       'this is a <script>'      => 'this is a &lt;script&gt;'