diff --git a/lib/redcloth3.rb b/lib/redcloth3.rb index a4d33f80..e99ccdf7 100644 --- a/lib/redcloth3.rb +++ b/lib/redcloth3.rb @@ -784,6 +784,7 @@ class RedCloth3 < String end LINK_RE = / + ( ([\s\[{(]|[#{PUNCT}])? # $pre " # start (#{C}) # $atts @@ -797,13 +798,16 @@ class RedCloth3 < String ) (\/)? # $slash ([^\w\=\/;\(\)]*?) # $post + ) (?=<|\s|$) /x #" def inline_textile_link( text ) text.gsub!( LINK_RE ) do |m| - pre,atts,text,title,url,proto,slash,post = $~[1..8] - + all,pre,atts,text,title,url,proto,slash,post = $~[1..9] + if text.include?('
') + all + else url, url_title = check_refs( url ) title ||= url_title @@ -821,6 +825,7 @@ class RedCloth3 < String external = (url =~ /^https?:\/\//) ? ' class="external"' : '' "#{ pre }#{ text }#{ post }" + end end end diff --git a/lib/redmine/wiki_formatting/textile/formatter.rb b/lib/redmine/wiki_formatting/textile/formatter.rb index 67e3579d..7e20c7bf 100644 --- a/lib/redmine/wiki_formatting/textile/formatter.rb +++ b/lib/redmine/wiki_formatting/textile/formatter.rb @@ -44,7 +44,7 @@ module Redmine # Patch for RedCloth. Fixed in RedCloth r128 but _why hasn't released it yet. # http://code.whytheluckystiff.net/redcloth/changeset/128 def hard_break( text ) - text.gsub!( /(.)\n(?!\n|\Z|>| *(>? *[#*=]+(\s|$)|[{|]))/, "\\1
\n" ) if hard_breaks + text.gsub!( /(.)\n(?!\n|\Z|>| *([#*=]+(\s|$)|[{|]))/, "\\1
" ) if hard_breaks end # Patch to add code highlighting support to RedCloth diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 4d771956..2dc50670 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -109,7 +109,7 @@ class ApplicationHelperTest < HelperTestCase '"link (Link title with "double-quotes")":http://foo.bar' => 'link', "This is not a \"Link\":\n\nAnother paragraph" => "This is not a \"Link\":

\n\n\n\t

Another paragraph", # no multiline link text - "This is a double quote \"on the first line\nand another on a second line\":test" => "This is a double quote \"on the first line
\nand another on a second line\":test", + "This is a double quote \"on the first line\nand another on a second line\":test" => "This is a double quote \"on the first line
and another on a second line\":test", # mailto link "\"system administrator\":mailto:sysadmin@example.com?subject=redmine%20permissions" => "system administrator", # two exclamation marks @@ -396,6 +396,45 @@ EXPECTED assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '') end + def test_table_with_line_breaks + raw = <<-RAW +This is a table with line breaks: + +|cell11 +continued|cell12|| +|-cell21-||cell23 +cell23 line2 +cell23 *line3*| +|cell31|cell32 +cell32 line2|cell33| + +RAW + + expected = <<-EXPECTED +

This is a table with line breaks:

+ + + + + + + + + + + + + + + + + +
cell11
continued
cell12
cell21cell23
cell23 line2
cell23 line3
cell31cell32
cell32 line2
cell33
+EXPECTED + + assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '') + end + def test_default_formatter Setting.text_formatting = 'unknown' text = 'a *link*: http://www.example.net/'