Module:template utilities/documentation

This module provides functions for finding and parsing template invocations found in wikitext, though it can also be used for other purposes.


 * lua
 * Finds a substring with balanced brackets. This means that, if one reads the string from left to right, counting +1 for a left bracket and -1 for a right bracket, the ending right bracket is the first right bracket where the count reaches 0. This function is similar to Lua search pattern lua, but accepts multi-character tokens as brackets.
 * lua: the string to be searched
 * lua: the left and right brackets to be searched for, given as a hash table with the left brackets being keys and the right being values. They are interpreted as Lua patterns:


 * lua: where in lua to start the search
 * Return value: If it finds a match, returns indices of where this bracket starts and ends, and the whole bracket substring (including the brackets); otherwise returns lua.


 * lua
 * Iterates through all top-level lua found in lua.
 * The parameters are the same as in lua.
 * Return value: Returns an iterator function. It yields indices of where this bracket starts and ends, and the whole bracket substring.


 * lua
 * Searches lua using lua, but ignore all text inside lua.
 * lua: the same parameters for lua
 * Other parameters are the same as in lua.
 * Return value: Returns the result of lua.


 * lua
 * Splits lua into substrings at boundaries that match the pattern lua and are not in any lua, and iterates through them.
 * lua: the pattern matching the boundaries. If it matches the empty string, s will be split into individual characters.
 * Other parameters are the same as in lua.
 * Return value: Returns an iterator function. It yields each section substring.


 * lua
 * Parses lua as a template invocation and returns the result table.
 * lua: the string of a template invocation
 * Return value: If success, returns a table containing the template name as a string lua and the parameters as a table lua; otherwise, returns lua.


 * lua
 * Iterates through all extant numbered parameters of a template. Named parameters are ignored. Nonexistent numbered parameters are skipped.
 * lua: a table containing the template name as a string lua and the parameters as a table lua
 * Return value: Returns an iterator function. It yields the index and values of all number-indexed non-nil content of the table in order.


 * lua
 * Serializes a template information table to template invocation wikitext. The inverse operation of lua.
 * lua: the same as in lua
 * Return value: Returns a string of template invocation wikitext. Raises errors when it fails.