Board Thread:Lua Help/@comment-4405550-20160124224015/@comment-4405550-20160206174003

Sorry for the long response :/ non-stop doubles at work.

...although using a mix of the parse API and revision API it is possible to do what the extension does in a somewhat limited way.

Thats how the module currently works. The API can also return a list of all the template calls make while parsing, which can be useful when preprocessing a page. Then just use a simple regular expression to extract template and #invoke calls.

Here is one I threw together that only returns well-formed template and #invoke calls (can handle up to 3 nested layers of templates/arguments): ([^\{]|^)(\{\{((\#invoke\s*)?\:?([\w\s\:\/\-\+\.\'\"\\]+?))\s*((?:(?:\s*\|)+(?:[^\|\{\}]*(?:\{\{[^\{\}]*(?:\{[^\{\}]*\{\{[^\{\}]*(?:\{(?:\{\{(?:\{[^\{\}]+\}|[^\{\}]+)\}\}[^\{\}]*)\}|(?:\{\{(?:\{[^\{\}]+\}|[^\{\}]+)\}\}[^\{\}]*))?\}\}\}[^\{\}]*|\{\{[^\{\}]*(?:\{(?:\{\{(?:\{[^\{\}]+\}|[^\{\}]+)\}\}[^\{\}]*)\}|(?:\{\{(?:\{[^\{\}]+\}|[^\{\}]+)\}\}[^\{\}]*))?\}\}[^\{\}]*)?\}\}[^\{\}]*|\{\{\{[^\{\}]*(?:\{\{(?:\{[^\{\}]+\}|[^\{\}]+)\}\}[^\{\}]*)?\}\}\}[^\{\}]*)|[^\|\{\}]+))*)\}\}) live example

It would be simpler/more effective if js had a stable PCRE package. But this would work for now.

But I think that it is probably up to date.

I believe "v0.10.36" is from before the io.js merger (but don't quote me on that).

It seems quite intuitive except for that whole package stuff. You usually don't have to worry about things like relative file I/O when writing a package, I was just being lazy trying to push out a "proof-of-concept" module before running off to work. Most users don't even know about "require.main.require". A well written module wouldn't do the actual file system I/O. It should instead be handled by the script requiring the module, and be passed in as a stream or blob.