Changes between Version 1 and Version 2 of TracWikiMacros


Ignore:
Timestamp:
May 30, 2008 2:26:51 PM (8 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracWikiMacros

    v1 v2  
    104104
    105105=== {{{expand_macro}}} details ===
    106 {{{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.
     106{{{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. You will also need to import Formatter using {{{from trac.wiki import Formatter}}}.
    107107
    108108If your macro creates wiki markup instead of HTML, you can convert it to HTML like this:
     
    113113  # Convert Wiki markup to HTML, new style
    114114  out = StringIO()
    115   Formatter(formatter.context).format(text, out)
     115  Formatter(self.env, formatter.context).format(text, out)
    116116  return Markup(out.getvalue())
    117117}}}