Hello, you have come here looking for the meaning of the word
Module:template utilities/documentation. In DICTIOUS you will not only get to know all the dictionary meanings for the word
Module:template utilities/documentation, but we will also tell you about its etymology, its characteristics and you will know how to say
Module:template utilities/documentation in singular and plural. Everything you need to know about the word
Module:template utilities/documentation you have here. The definition of the word
Module:template utilities/documentation will help you to be more precise and correct when speaking or writing your texts. Knowing the definition of
Module:template utilities/documentation, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
This module provides functions for finding and parsing template invocations found in wikitext, though it can also be used for other purposes.
find_bracket(str, brackets, p_start)
- 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
'%b'
, but accepts multi-character tokens as brackets.
str
: the string to be searched
brackets
: 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:
p_start
: where in str
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
nil
.
gfind_bracket(str, brackets)
- Iterates through all top-level
brackets
found in str
.
- The parameters are the same as in
find_bracket()
.
- Return value: Returns an iterator function. It yields indices of where this bracket starts and ends, and the whole bracket substring.
find_ignoring_brackets(str, brackets, pat, init, ...)
- Searches
str
using string.find()
, but ignore all text inside brackets
.
pat, init, ...
: the same parameters for string.find()
- Other parameters are the same as in
find_bracket()
.
- Return value: Returns the result of
string.find()
.
gsplit_ignoring_brackets
- Splits
str
into substrings at boundaries that match the pattern sep
and are not in any brackets
, and iterates through them.
sep
: 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
find_bracket()
.
- Return value: Returns an iterator function. It yields each section substring.
parse_temp(str)
- Parses
str
as a template invocation and returns the result table.
str
: the string of a template invocation
- Return value: If success, returns a table containing the template name as a string
and the parameters as a table
; otherwise, returns nil
.
iter_num(t)
- Iterates through all extant numbered parameters of a template. Named parameters are ignored. Nonexistent numbered parameters are skipped.
t
: a table containing the template name as a string
and the parameters as a table
- Return value: Returns an iterator function. It yields the index and values of all number-indexed non-nil content of the table in order.
glue_temp(t)
- Serializes a template information table to template invocation wikitext. The inverse operation of
parse_temp(str)
.
t
: the same as in iter_num(t)
- Return value: Returns a string of template invocation wikitext. Raises errors when it fails.