]> source.dussan.org Git - redmine.git/commitdiff
Fixed that lines with spaces only before headings break wiki section extraction ...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 11 Jun 2012 17:51:14 +0000 (17:51 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 11 Jun 2012 17:51:14 +0000 (17:51 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9822 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/wiki_formatting/textile/formatter.rb
test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb

index cfcc7f77c213b85d53240fb191dc090a975342b3..b06ee64e781dac61b09e612f72aa352ce238fef1 100644 (file)
@@ -69,7 +69,7 @@ module Redmine
           l = 1
           started = false
           ended = false
-          text.scan(/(((?:.*?)(\A|\r?\n\r?\n))(h(\d+)(#{A}#{C})\.(?::(\S+))? (.*?)$)|.*)/m).each do |all, content, lf, heading, level|
+          text.scan(/(((?:.*?)(\A|\r?\n\s*\r?\n))(h(\d+)(#{A}#{C})\.(?::(\S+))? (.*?)$)|.*)/m).each do |all, content, lf, heading, level|
             if heading.nil?
               if ended
                 after << all
index 3f33e5eb7ee4e1681981e381d9668baaea238366..26f9993d0d11139966a7d08dd4d7a196a24a1980 100644 (file)
@@ -394,6 +394,31 @@ Nulla nunc nisi, egestas in ornare vel, posuere ac libero."]
       @formatter.new(text).update_section(3, replacement)
   end
 
+  def test_get_section_should_support_lines_with_spaces_before_heading
+    # the lines after Content 2 and Heading 4 contain a space
+    text = <<-STR
+h1. Heading 1
+
+Content 1
+
+h1. Heading 2
+
+Content 2
+h1. Heading 3
+
+Content 3
+
+h1. Heading 4
+Content 4
+STR
+
+    [1, 2, 3, 4].each do |index|
+      assert_match /\Ah1. Heading #{index}.+Content #{index}/m, @formatter.new(text).get_section(index).first
+    end
+  end
+
   private
 
   def assert_html_output(to_test, expect_paragraph = true)