diff --git a/trac/wiki/api.py b/trac/wiki/api.py
|
a
|
b
|
|
| 82 | 82 | def render_macro(req, name, content): |
| 83 | 83 | """Return the HTML output of the macro (deprecated)""" |
| 84 | 84 | |
| 85 | | def expand_macro(formatter, name, content): |
| | 85 | def expand_macro(formatter, name, content, args={}): |
| 86 | 86 | """Called by the formatter when rendering the parsed wiki text. |
| 87 | 87 | |
| | 88 | `content` is the content of the macro call. When called using macro |
| | 89 | syntax (`[[Macro(content)]]`), this is the string contained between |
| | 90 | parentheses, usually containing macro arguments. When called using wiki |
| | 91 | processor syntax (`{{{!#Macro ...}}}`), it is the content of the |
| | 92 | processor block, that is, the text starting on the line following the |
| | 93 | macro name. In this case, `args` contains the named arguments passed on |
| | 94 | the same line as the macro name. |
| | 95 | |
| 88 | 96 | (since 0.11) |
| 89 | 97 | """ |
| 90 | 98 | |
diff --git a/trac/wiki/formatter.py b/trac/wiki/formatter.py
|
a
|
b
|
|
| 34 | 34 | from trac.resource import get_relative_resource, get_resource_url |
| 35 | 35 | from trac.wiki.api import WikiSystem, parse_args |
| 36 | 36 | from trac.wiki.parser import WikiParser |
| | 37 | from trac.util import arity |
| 37 | 38 | from trac.util.text import exception_to_unicode, shorten_line, to_unicode, \ |
| 38 | 39 | unicode_quote, unicode_quote_plus |
| 39 | 40 | from trac.util.html import TracHTMLSanitizer |
| … |
… |
|
| 175 | 176 | def _macro_processor(self, text): |
| 176 | 177 | self.env.log.debug('Executing Wiki macro %s by provider %s' |
| 177 | 178 | % (self.name, self.macro_provider)) |
| 178 | | return self.macro_provider.expand_macro(self.formatter, self.name, |
| 179 | | text) |
| | 179 | if arity(self.macro_provider.expand_macro) == 5: |
| | 180 | return self.macro_provider.expand_macro(self.formatter, self.name, |
| | 181 | text, self.args) |
| | 182 | else: |
| | 183 | return self.macro_provider.expand_macro(self.formatter, self.name, |
| | 184 | text) |
| 180 | 185 | |
| 181 | 186 | def _mimeview_processor(self, text): |
| 182 | 187 | return Mimeview(self.env).render(self.formatter.context, |
| … |
… |
|
| 796 | 801 | match = WikiParser._processor_re.match(line) |
| 797 | 802 | if match: |
| 798 | 803 | name = match.group(1) |
| 799 | | args = WikiParser._processor_param_re.split(line[len(name):]) |
| | 804 | args = WikiParser._processor_param_re.split(line[2+len(name):]) |
| 800 | 805 | del args[::3] |
| 801 | 806 | keys = [str(k) for k in args[::2]] # used as keyword parameters |
| 802 | 807 | values = [(v and v[0] in '"\'' and [v[1:-1]] or [v])[0] |