##// END OF EJS Templates
Allow line breaks in wiki table cells (#2346)....
Jean-Philippe Lang -
r2719:dcba9f18e6f3
parent child
Show More
@@ -784,6 +784,7 class RedCloth3 < String
784 end
784 end
785
785
786 LINK_RE = /
786 LINK_RE = /
787 (
787 ([\s\[{(]|[#{PUNCT}])? # $pre
788 ([\s\[{(]|[#{PUNCT}])? # $pre
788 " # start
789 " # start
789 (#{C}) # $atts
790 (#{C}) # $atts
@@ -797,13 +798,16 class RedCloth3 < String
797 )
798 )
798 (\/)? # $slash
799 (\/)? # $slash
799 ([^\w\=\/;\(\)]*?) # $post
800 ([^\w\=\/;\(\)]*?) # $post
801 )
800 (?=<|\s|$)
802 (?=<|\s|$)
801 /x
803 /x
802 #"
804 #"
803 def inline_textile_link( text )
805 def inline_textile_link( text )
804 text.gsub!( LINK_RE ) do |m|
806 text.gsub!( LINK_RE ) do |m|
805 pre,atts,text,title,url,proto,slash,post = $~[1..8]
807 all,pre,atts,text,title,url,proto,slash,post = $~[1..9]
806
808 if text.include?('<br />')
809 all
810 else
807 url, url_title = check_refs( url )
811 url, url_title = check_refs( url )
808 title ||= url_title
812 title ||= url_title
809
813
@@ -821,6 +825,7 class RedCloth3 < String
821 external = (url =~ /^https?:\/\//) ? ' class="external"' : ''
825 external = (url =~ /^https?:\/\//) ? ' class="external"' : ''
822
826
823 "#{ pre }<a#{ atts }#{ external }>#{ text }</a>#{ post }"
827 "#{ pre }<a#{ atts }#{ external }>#{ text }</a>#{ post }"
828 end
824 end
829 end
825 end
830 end
826
831
@@ -44,7 +44,7 module Redmine
44 # Patch for RedCloth. Fixed in RedCloth r128 but _why hasn't released it yet.
44 # Patch for RedCloth. Fixed in RedCloth r128 but _why hasn't released it yet.
45 # <a href="http://code.whytheluckystiff.net/redcloth/changeset/128">http://code.whytheluckystiff.net/redcloth/changeset/128</a>
45 # <a href="http://code.whytheluckystiff.net/redcloth/changeset/128">http://code.whytheluckystiff.net/redcloth/changeset/128</a>
46 def hard_break( text )
46 def hard_break( text )
47 text.gsub!( /(.)\n(?!\n|\Z|>| *(>? *[#*=]+(\s|$)|[{|]))/, "\\1<br />\n" ) if hard_breaks
47 text.gsub!( /(.)\n(?!\n|\Z|>| *([#*=]+(\s|$)|[{|]))/, "\\1<br />" ) if hard_breaks
48 end
48 end
49
49
50 # Patch to add code highlighting support to RedCloth
50 # Patch to add code highlighting support to RedCloth
@@ -109,7 +109,7 class ApplicationHelperTest < HelperTestCase
109 '"link (Link title with "double-quotes")":http://foo.bar' => '<a href="http://foo.bar" title="Link title with &quot;double-quotes&quot;" class="external">link</a>',
109 '"link (Link title with "double-quotes")":http://foo.bar' => '<a href="http://foo.bar" title="Link title with &quot;double-quotes&quot;" class="external">link</a>',
110 "This is not a \"Link\":\n\nAnother paragraph" => "This is not a \"Link\":</p>\n\n\n\t<p>Another paragraph",
110 "This is not a \"Link\":\n\nAnother paragraph" => "This is not a \"Link\":</p>\n\n\n\t<p>Another paragraph",
111 # no multiline link text
111 # no multiline link text
112 "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",
112 "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",
113 # mailto link
113 # mailto link
114 "\"system administrator\":mailto:sysadmin@example.com?subject=redmine%20permissions" => "<a href=\"mailto:sysadmin@example.com?subject=redmine%20permissions\">system administrator</a>",
114 "\"system administrator\":mailto:sysadmin@example.com?subject=redmine%20permissions" => "<a href=\"mailto:sysadmin@example.com?subject=redmine%20permissions\">system administrator</a>",
115 # two exclamation marks
115 # two exclamation marks
@@ -396,6 +396,45 EXPECTED
396 assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
396 assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
397 end
397 end
398
398
399 def test_table_with_line_breaks
400 raw = <<-RAW
401 This is a table with line breaks:
402
403 |cell11
404 continued|cell12||
405 |-cell21-||cell23
406 cell23 line2
407 cell23 *line3*|
408 |cell31|cell32
409 cell32 line2|cell33|
410
411 RAW
412
413 expected = <<-EXPECTED
414 <p>This is a table with line breaks:</p>
415
416 <table>
417 <tr>
418 <td>cell11<br />continued</td>
419 <td>cell12</td>
420 <td></td>
421 </tr>
422 <tr>
423 <td><del>cell21</del></td>
424 <td></td>
425 <td>cell23<br/>cell23 line2<br/>cell23 <strong>line3</strong></td>
426 </tr>
427 <tr>
428 <td>cell31</td>
429 <td>cell32<br/>cell32 line2</td>
430 <td>cell33</td>
431 </tr>
432 </table>
433 EXPECTED
434
435 assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
436 end
437
399 def test_default_formatter
438 def test_default_formatter
400 Setting.text_formatting = 'unknown'
439 Setting.text_formatting = 'unknown'
401 text = 'a *link*: http://www.example.net/'
440 text = 'a *link*: http://www.example.net/'
General Comments 0
You need to be logged in to leave comments. Login now