On Thu, Dec 18, 2008 at 2:54 PM, Noah Kantrowitz <[email protected]> wrote:
>
> No, that is correct. Trac doesn't use a multi-pass wiki formatter. Macros
> cannot be put anywhere you want, they are a paragraph level construct.

I decided macros could be put anywhere in my installation (where only
trusted admins can change the wiki):

== [[GetOption(project,name)]]-[[GetOption(project,contractNumber)]] Home ==

It doesn't particularly matter what your macro outputs, I but mine is simple:

------------start macro
from trac.wiki.macros import WikiMacroBase

class GetOptionMacro(WikiMacroBase):
    """Inserts the specified trac.ini option into the wiki page"""

    def expand_macro(self, formatter, name, args):
        arglist = [x.strip() for x in args.split(',')]
        try:
            return self.config.get(arglist[0], arglist[1])
        except:
            return "[[GetOption(%s)]]" % args
----------end macro

Patch:

--- C:/TracDev/trunk.export/trac/wiki/formatter.py      Sat Nov 08 16:19:46 2008
+++ C:/Python25/lib/site-packages/Trac-0.12dev-py2.5.egg/trac/wiki/formatter.py 
Wed
Dec 10 16:04:26 2008
@@ -925,15 +925,15 @@
     def _table_cell_formatter(self, match, fullmatch): return match
     def _last_table_cell_formatter(self, match, fullmatch): return match

-    def _macro_formatter(self, match, fullmatch):
-        name = fullmatch.group('macroname')
-        if name.lower() == 'br':
-            return ' '
-        elif name == 'comment':
-            return ''
-        else:
-            args = fullmatch.group('macroargs')
-            return '[[%s%s]]' % (name,  args and '(...)' or '')
+#    def _macro_formatter(self, match, fullmatch):
+#        name = fullmatch.group('macroname')
+#        if name.lower() == 'br':
+#            return ' '
+#        elif name == 'comment':
+#            return ''
+#        else:
+#            args = fullmatch.group('macroargs')
+#            return '[[%s%s]]' % (name,  args and '(...)' or '')

     def format(self, text, out, shorten=False):
         if not text:

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/trac-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to