Allow line breaks in wiki table cells (#2346).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2824 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
5ec4d4cdab
commit
dcba9f18e6
|
@ -784,6 +784,7 @@ class RedCloth3 < String
|
||||||
end
|
end
|
||||||
|
|
||||||
LINK_RE = /
|
LINK_RE = /
|
||||||
|
(
|
||||||
([\s\[{(]|[#{PUNCT}])? # $pre
|
([\s\[{(]|[#{PUNCT}])? # $pre
|
||||||
" # start
|
" # start
|
||||||
(#{C}) # $atts
|
(#{C}) # $atts
|
||||||
|
@ -797,13 +798,16 @@ class RedCloth3 < String
|
||||||
)
|
)
|
||||||
(\/)? # $slash
|
(\/)? # $slash
|
||||||
([^\w\=\/;\(\)]*?) # $post
|
([^\w\=\/;\(\)]*?) # $post
|
||||||
|
)
|
||||||
(?=<|\s|$)
|
(?=<|\s|$)
|
||||||
/x
|
/x
|
||||||
#"
|
#"
|
||||||
def inline_textile_link( text )
|
def inline_textile_link( text )
|
||||||
text.gsub!( LINK_RE ) do |m|
|
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?('<br />')
|
||||||
|
all
|
||||||
|
else
|
||||||
url, url_title = check_refs( url )
|
url, url_title = check_refs( url )
|
||||||
title ||= url_title
|
title ||= url_title
|
||||||
|
|
||||||
|
@ -823,6 +827,7 @@ class RedCloth3 < String
|
||||||
"#{ pre }<a#{ atts }#{ external }>#{ text }</a>#{ post }"
|
"#{ pre }<a#{ atts }#{ external }>#{ text }</a>#{ post }"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
MARKDOWN_REFLINK_RE = /
|
MARKDOWN_REFLINK_RE = /
|
||||||
\[([^\[\]]+)\] # $text
|
\[([^\[\]]+)\] # $text
|
||||||
|
|
|
@ -44,7 +44,7 @@ module Redmine
|
||||||
# Patch for RedCloth. Fixed in RedCloth r128 but _why hasn't released it yet.
|
# Patch for RedCloth. Fixed in RedCloth r128 but _why hasn't released it yet.
|
||||||
# <a href="http://code.whytheluckystiff.net/redcloth/changeset/128">http://code.whytheluckystiff.net/redcloth/changeset/128</a>
|
# <a href="http://code.whytheluckystiff.net/redcloth/changeset/128">http://code.whytheluckystiff.net/redcloth/changeset/128</a>
|
||||||
def hard_break( text )
|
def hard_break( text )
|
||||||
text.gsub!( /(.)\n(?!\n|\Z|>| *(>? *[#*=]+(\s|$)|[{|]))/, "\\1<br />\n" ) if hard_breaks
|
text.gsub!( /(.)\n(?!\n|\Z|>| *([#*=]+(\s|$)|[{|]))/, "\\1<br />" ) if hard_breaks
|
||||||
end
|
end
|
||||||
|
|
||||||
# Patch to add code highlighting support to RedCloth
|
# Patch to add code highlighting support to RedCloth
|
||||||
|
|
|
@ -109,7 +109,7 @@ class ApplicationHelperTest < HelperTestCase
|
||||||
'"link (Link title with "double-quotes")":http://foo.bar' => '<a href="http://foo.bar" title="Link title with "double-quotes"" class="external">link</a>',
|
'"link (Link title with "double-quotes")":http://foo.bar' => '<a href="http://foo.bar" title="Link title with "double-quotes"" class="external">link</a>',
|
||||||
"This is not a \"Link\":\n\nAnother paragraph" => "This is not a \"Link\":</p>\n\n\n\t<p>Another paragraph",
|
"This is not a \"Link\":\n\nAnother paragraph" => "This is not a \"Link\":</p>\n\n\n\t<p>Another paragraph",
|
||||||
# no multiline link text
|
# 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<br />\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<br />and another on a second line\":test",
|
||||||
# mailto link
|
# mailto link
|
||||||
"\"system administrator\":mailto:sysadmin@example.com?subject=redmine%20permissions" => "<a href=\"mailto:sysadmin@example.com?subject=redmine%20permissions\">system administrator</a>",
|
"\"system administrator\":mailto:sysadmin@example.com?subject=redmine%20permissions" => "<a href=\"mailto:sysadmin@example.com?subject=redmine%20permissions\">system administrator</a>",
|
||||||
# two exclamation marks
|
# two exclamation marks
|
||||||
|
@ -396,6 +396,45 @@ EXPECTED
|
||||||
assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
|
assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
|
||||||
end
|
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
|
||||||
|
<p>This is a table with line breaks:</p>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>cell11<br />continued</td>
|
||||||
|
<td>cell12</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><del>cell21</del></td>
|
||||||
|
<td></td>
|
||||||
|
<td>cell23<br/>cell23 line2<br/>cell23 <strong>line3</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>cell31</td>
|
||||||
|
<td>cell32<br/>cell32 line2</td>
|
||||||
|
<td>cell33</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
EXPECTED
|
||||||
|
|
||||||
|
assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
|
||||||
|
end
|
||||||
|
|
||||||
def test_default_formatter
|
def test_default_formatter
|
||||||
Setting.text_formatting = 'unknown'
|
Setting.text_formatting = 'unknown'
|
||||||
text = 'a *link*: http://www.example.net/'
|
text = 'a *link*: http://www.example.net/'
|
||||||
|
|
Loading…
Reference in New Issue