Module:Wikitext Parsing/doc explained

This module provides some functions to help with the potential complex situation involved in modules like, which intend to process the raw wikitext of a page and want to respect nowiki tags or similar reliably. This module is designed only to be called by other modules.

PrepareText

PrepareText(text, keepComments) will run any content within certain tags that disable processing through mw.text.nowiki and remove HTML comments to avoid irrelevant text being processed by modules, allowing tricky syntax to be parsed through more basic means such as %b{}.

If the second parameter, keepComments, is set to true, the content of HTML comments will be passed through mw.text.nowiki instead of being removed entirely.

Any code using this function directly should consider using mw.text.decode to correct the output at the end if part of the processed text is returned, though this will also decode any input that was encoded but not inside a no-processing tag, which likely isn't a significant issue but still something worth considering.

ParseTemplates

ParseTemplates(InputText, dontEscape) will attempt to parse all <nowiki>{{Templates}}</nowiki> on a page, handling multiple factors such as <nowiki>[[Wikilinks]]</nowiki> and <nowiki>{{{Variables}}}</nowiki> among other complex syntax. Due to the complexity of the function, it is considerably slow, and should be used carefully. The function returns a list of template objects in order of appearance, which have the following properties:

If the second parameter, dontEscape, is set to true, the inputted text won't be ran through the PrepareText function.