
tstarling at wikimedia
May 1, 2012, 12:15 AM
Views: 259
Permalink
|
I've written up a proposed interface between the MediaWiki parser and Lua: <https://www.mediawiki.org/wiki/Extension:Scribunto/Parser_interface_design> In summary: the Lua function is called with a single argument, which is an object representing the parser interface. The object is roughly equivalent to a PPFrame. The object would have a property called "args", which is a table with its "index" metamethod overridden to provide lazy-initialised access to the parser function arguments with a brief syntax: {{#invoke:module|func|name=value}} function p.func(frame) return frame.args.name --- returns "value" end There would be two methods for recursive preprocessing: * preprocess() provides basic expansion of wikitext * callTemplate() provides an API for template invocation, since I imagine that would otherwise be a common use case for preprocess(). Using preprocess() to expand a template with arbitrary arguments would be difficult. Like a normal parser function, the Lua function returns text which is not modified any further by the preprocessor. Please see the wiki page for a more detailed description, including rationale. Any comments would be greatly appreciated. -- Tim Starling _______________________________________________ Wikitech-l mailing list Wikitech-l [at] lists https://lists.wikimedia.org/mailman/listinfo/wikitech-l
|