]> source.dussan.org Git - redmine.git/commitdiff
Slight change to the macro regexp.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 8 Aug 2012 18:54:01 +0000 (18:54 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 8 Aug 2012 18:54:01 +0000 (18:54 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10178 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/unit/lib/redmine/wiki_formatting/macros_test.rb

index 2245944c85b9414a91dc814e526761e1968d0998..983f3fd8be9aca5c1ccfb57ef5a1bda1ca9e4c84 100644 (file)
@@ -852,7 +852,7 @@ module ApplicationHelper
                 (
                 \{\{                        # opening tag
                 ([\w]+)                     # macro name
-                (\(([^\}]*)\))?             # optional arguments
+                (\((.*?)\))?                # optional arguments
                 \}\}                        # closing tag
                 )
               /x unless const_defined?(:MACROS_RE)
index 4583d3e9b0053a4a235e1de80b3dabb8a953a6cc..42885a7dfd9eebae447f7f57088062617839dfd3 100644 (file)
@@ -65,6 +65,17 @@ class Redmine::WikiFormatting::MacrosTest < ActionView::TestCase
     assert_equal '<p>Bar: () (String)</p>', textilizable("{{bar()}}")
   end
 
+  def test_multiple_macros_on_the_same_line
+    Redmine::WikiFormatting::Macros.macro :foo do |obj, args|
+      args.any? ? "args: #{args.join(',')}" : "no args" 
+    end
+
+    assert_equal '<p>no args no args</p>', textilizable("{{foo}} {{foo}}")
+    assert_equal '<p>args: a,b no args</p>', textilizable("{{foo(a,b)}} {{foo}}")
+    assert_equal '<p>args: a,b args: c,d</p>', textilizable("{{foo(a,b)}} {{foo(c,d)}}")
+    assert_equal '<p>no args args: c,d</p>', textilizable("{{foo}} {{foo(c,d)}}")
+  end
+
   def test_macro_hello_world
     text = "{{hello_world}}"
     assert textilizable(text).match(/Hello world!/)