Manual:Parser.php

Description
This file contains among other things class Parser, which contains function parse, which is called from function addPrimaryWikiText in OutputPage.php   for parsing the wikitext $text. This function parse calls function strip, which strips and renders nowiki, pre, math, and hiero; e.g., each text between nowiki tags is replaced by a temporary code which at the end is replaced by the original text in an unstrip operation. After that XML-style tags of extensions are processed.

There is a hook before and after this call of strip, see the next section. After that the function calls function internalParse, which converts the string $text from wikitext to HTML.

This function starts with hook ParserBeforeInternalParse and calls, in this order:


 * Function replaceVariables: recursively expands variables, templates, and template parameters; it calls:
 * Function replace_callback: parses the wikitext with respect to pairs of double and triple braces.
 * Function braceSubstitution: expands variables and templates.
 * If there are no pipes it calls function variableSubstitution.
 * If the text between the braces is the name of a variable it calls function getVariableValue.
 * For evaluating variables depending on time the PHP functions "time" and "date"  are called.
 * If we have, after the opening braces, the title of a core parser function and then a colon, the function concerned in CoreParserFunctions.php is called.
 * Function createAssocArgs: converts an array of parameter definitions such "a=3", "5", "a=4", and "8" into an associative array with the parameter names a, 1, and 2 as indexes and parameter values 4, 5, and 8 as array values.
 * Function argSubstitution: expands template parameters.
 * Function doHeadings: replaces header codes: ==a== becomes a etc.
 * Function reformat in DateFormatter.php: converts dates and times according to preferences
 * Function doAllQuotes: replaces double and triple quotation marks by  and .
 * Function replaceInternalLinks: converts the internal links to HTML.
 * Function replaceExternalLinks: converts the external links to HTML.

After that there is tidying, with a hook before and after it.

The file also contains function preprocess, used for Special:ExpandTemplates, which contains a call of function replaceVariables between a strip and unstrip call.

Further the file contains function setFunctionHook, called when setting up a function, and associating the magic_word_id of a parser function with the name of the PHP function defining it (see also parser function extensions). This information is stored in array mFunctionHooks. Also the array mFunctionSynonyms is created, with a case-sensitivy boolean as index, and as value an array with the magic words that can be used in the wikitext as indexes, and the magic word id's as values. These arrays are used during the parsing.