This is a static copy of the main wikispot.org site, preserved for historical purposes only. Please see this page for more information.

Hacking Macros

InfoInfo
Search:    

Macros are defined by double brackets [[]]. Macros tell to the wiki parser to replace an input pattern with specific output.

An example macro: [[Foo(bar,barbar,barfoo)]]

In Sycamore, the macro script is found in Sycamore/macro/foo.py

The function the macro calls when it's run is execute, E.g. def execute(macro, args, formatter). The argument macro is a copy of the macro object. The macro object contains things such as the request object and the parser object. The argument args is a string, which is exactly what is in the () in the call. In the above example, this would be "bar,barbar,barfoo". The formatter argument is a copy of the formatter object (which renders wiki markup tokens into HTML). For instance, to create a linebreak in the HTML without actually doing macro.request.write("<br/>") you could call macro.formatter.linebreak(0). More examples can be found throughout the code.

This is a Wiki Spot wiki. Wiki Spot is a 501(c)3 non-profit organization that helps communities collaborate via wikis.