The macros defined and used in WikkiTikkiTavi, as listed in TaviMacros, are references in two arrays; namely $ViewMacroEngine and $SaveMacroEngine. When 'Tavi see a macro call, as indicated by [[...]] it uses the first word as an entry point into these arrays. The first for display macros, and the second for on-save macros. It then replaces the macro call with the output of the macro function, as indicated by arguments and options.

If you want to make an extra macro, you don't need to worry about how to parse a macro call. You just need to name your macro, and add it to the approriate array.

Options and arguments

As of version 0.24 the macros may have two kind of options or arguments. Options, used to change the looks of the results, are optional and if present they must be stated within curly braces. All other text are arguments to the macro. Arguments are stuff needed for the macro to function, i.e. page name or search patterns. Not all macros uses arguments or options.

An example:

[[MacroName {options,more=options} firstArgument SecondArgument {thirdArgument}]]

Note that thirdArgument is an argument since it's not the first word/text after the macroname. Options are sometimes referred to as CurlyOptions as they are used in an increasing number of areas to give options to the different formatting codes in 'Tavi.

For the developer it's nice to remember that the arguments/options passed to your function are simple strings. You do need to do a [explode()], [preg_split()] or [split()] on the string given to your macro. This means that in the new regime macros should accept two parameters, $args and $opts, and these are simple strings which needs to be exploded/splitted.