| 100 | === {{{expand_macro}}} details === |
| 101 | {{{expand_macro}}} should return either a simple Python string which will be interpreted as HTML, or preferably a Markup object (use {{{from trac.util.html import Markup}}}). {{{Markup(string)}}} just annotates the string so the renderer will render the HTML string as-is with no escaping. |
| 102 | |
| 103 | If your macro creates wiki markup instead of HTML, you can convert it to HTML like this: |
| 104 | |
| 105 | {{{ |
| 106 | text = "whatever wiki markup you want, even containing other macros" |
| 107 | # Convert Wiki markup to HTML, new style |
| 108 | out = StringIO() |
| 109 | Formatter(formatter.context).format(text, out) |
| 110 | return Markup(out.getvalue()) |
| 111 | }}} |