Edgewall Software

Changes between Version 14 and Version 15 of 0.11/TracMacros


Ignore:
Timestamp:
Sep 21, 2007, 3:35:53 PM (17 years ago)
Author:
garyo@…
Comment:

Added return info for expand_macro, and how to convert wiki markup to HTML

Legend:

Unmodified
Added
Removed
Modified
  • 0.11/TracMacros

    v14 v15  
    9898
    9999
     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
     103If 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}}}