From 081ee54bee62a63a8cece6686f5ecf48c608f231 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 17 Jun 2012 08:52:40 +0000 Subject: [PATCH] Merged r9822 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9840 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .../wiki_formatting/textile/formatter.rb | 2 +- .../wiki_formatting/textile_formatter_test.rb | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/redmine/wiki_formatting/textile/formatter.rb b/lib/redmine/wiki_formatting/textile/formatter.rb index cfcc7f77c..b06ee64e7 100644 --- a/lib/redmine/wiki_formatting/textile/formatter.rb +++ b/lib/redmine/wiki_formatting/textile/formatter.rb @@ -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 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 3f33e5eb7..26f9993d0 100644 --- a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb @@ -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) -- 2.39.5