diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2245944..983f3fd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -852,7 +852,7 @@ module ApplicationHelper ( \{\{ # opening tag ([\w]+) # macro name - (\(([^\}]*)\))? # optional arguments + (\((.*?)\))? # optional arguments \}\} # closing tag ) /x unless const_defined?(:MACROS_RE) diff --git a/test/unit/lib/redmine/wiki_formatting/macros_test.rb b/test/unit/lib/redmine/wiki_formatting/macros_test.rb index 4583d3e..42885a7 100644 --- a/test/unit/lib/redmine/wiki_formatting/macros_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/macros_test.rb @@ -65,6 +65,17 @@ class Redmine::WikiFormatting::MacrosTest < ActionView::TestCase assert_equal '
Bar: () (String)
', 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 'no args no args
', textilizable("{{foo}} {{foo}}") + assert_equal 'args: a,b no args
', textilizable("{{foo(a,b)}} {{foo}}") + assert_equal 'args: a,b args: c,d
', textilizable("{{foo(a,b)}} {{foo(c,d)}}") + assert_equal 'no args args: c,d
', textilizable("{{foo}} {{foo(c,d)}}") + end + def test_macro_hello_world text = "{{hello_world}}" assert textilizable(text).match(/Hello world!/)