]> source.dussan.org Git - redmine.git/commitdiff
Wiki links:
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 21 Mar 2008 17:39:02 +0000 (17:39 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 21 Mar 2008 17:39:02 +0000 (17:39 +0000)
* fixes wiki links with pipe in table (closes #893, #870, #894)
* prevent wiki link matching on multiple lines

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1280 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
lib/redcloth.rb
test/unit/helpers/application_helper_test.rb

index f3b16bb260a8eec3be8c5f3c5dd490e2e76b97ae..510ecd15ebebb9d7e5377efc7e5fe4aa74185cbd 100644 (file)
@@ -239,7 +239,7 @@ module ApplicationHelper
     #   [[project:|mytext]]
     #   [[project:mypage]]
     #   [[project:mypage|mytext]]
-    text = text.gsub(/(!)?(\[\[([^\]\|]+)(\|([^\]\|]+))?\]\])/) do |m|
+    text = text.gsub(/(!)?(\[\[([^\]\n\|]+)(\|([^\]\n\|]+))?\]\])/) do |m|
       link_project = project
       esc, all, page, title = $1, $2, $3, $5
       if esc.nil?
index 14940cb884c598facf45e66223a82c04cac1255a..9452c267076a710345101b347bb76383d6e0190c 100644 (file)
@@ -510,7 +510,8 @@ class RedCloth < String
                 ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\. )(.*)/m
                 
                 cells = []
-                row.split( '|' ).each do |cell|
+                #row.split( /\(?!\[\[[^\]])|(?![^\[]\]\])/ ).each do |cell|
+                row.split( /\|(?![^\[\|]*\]\])/ ).each do |cell|
                     ctyp = 'd'
                     ctyp = 'h' if cell =~ /^_/
 
index 2b90b8f4b8072ba4a9359989e42b78c4d5b0d2f4..66499c0034110f4d55f8ffb3132b26e5f3a74b6d 100644 (file)
@@ -142,7 +142,21 @@ class ApplicationHelperTest < HelperTestCase
       "<pre><div>content</div></pre>" => "<pre>&lt;div&gt;content&lt;/div&gt;</pre>",
     }
     to_test.each { |text, result| assert_equal result, textilizable(text) }
-
+  end
+  
+  def test_wiki_links_in_tables
+    to_test = {"|Cell 11|Cell 12|Cell 13|\n|Cell 21|Cell 22||\n|Cell 31||Cell 33|" => 
+                 '<tr><td>Cell 11</td><td>Cell 12</td><td>Cell 13</td></tr>' +
+                 '<tr><td>Cell 21</td><td>Cell 22</td></tr>' +
+                 '<tr><td>Cell 31</td><td>Cell 33</td></tr>',
+                 
+               "|[[Page|Link title]]|[[Other Page|Other title]]|\n|Cell 21|[[Last page]]|" =>
+                 '<tr><td><a href="/wiki/ecookbook/Page" class="wiki-page new">Link title</a></td>' +
+                 '<td><a href="/wiki/ecookbook/Other_Page" class="wiki-page new">Other title</a></td>' +
+                 '</tr><tr><td>Cell 21</td><td><a href="/wiki/ecookbook/Last_page" class="wiki-page new">Last page</a></td></tr>'
+    }
+    @project = Project.find(1)
+    to_test.each { |text, result| assert_equal "<table>#{result}</table>", textilizable(text).gsub(/[\t\n]/, '') }
   end
   
   def test_macro_hello_world