1 May 2012 20:51
Re: Lua: parser interface
Gabriel Wicke <wicke <at> wikidev.net>
2012-05-01 18:51:50 GMT
2012-05-01 18:51:50 GMT
On 05/01/2012 09:15 AM, Tim Starling wrote:
> 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.
+1 for the abstract frame object.
> 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
An alternative to a wikitext-specific preprocess() method and plain-text
argument values could be a conversion / expansion method on an opaque
'parser value' object:
frame.args.name.expandTo( 'text/x-mediawiki' ) --- returns "value"
This would make it possible to work with other formats apart from wikitext.
I recently added an API like this in Parsoid (the method is called 'as'
(Continue reading)
RSS Feed