This manual's page is outdated. It was written for an older version of MediaWiki and may not apply to the most recent version. See the talk page for a possible discussion on this.
This file contains the class Parser, which contains the method parse, which converts Wikitext to HTML. It performs, among other things, the following actions:
Call helper function Parser::internalParse(), which in turns calls
Parser::replaceVariables, which replaces magic variables, templates, and template arguments with the appropriate text.
It calls Parser::preprocessToDom, which preprocesses some wikitext and returns the document tree.
Next it creates a PPFrame DOM object and calls its expand() method to do the actual template magic.
Sanitizer::removeHTMLtags(), which cleans up HTML, removes dangerous tags and attributes, and removes HTML comments.
Parser::doTableStuff, which handles and renders the wikitext for tables.
Parser::doDoubleUnderscore, which removes valid double-underscore items, like __NOTOC__, and records them in array $Parser->mDoubleUnderscores.
Parser::doHeadings, which parses and renders section headers.
Parser::replaceInternalLinks, which processes internal links ([[ ]]) and stores them in $Parser->mLinkHolders (a LinkHolderArray object),
Parser::doAllQuotes, which replaces single quotes with HTML markup (<i>, <b>, etc).
Parser::replaceExternalLinks, which replaces and renders external links.
Parser::doMagicLinks, which replaces special strings like "ISBN xxx" and "RFC xxx" with magic external links.
Parser::formatHeadings, which:
auto numbers headings if that options is enabled,
adds an [edit] link to sections for users who have enabled the option and can edit the page,
adds a Table of contents on the top for users who have enabled the option, and
auto-anchors headings.
Next, parse() calls Parser::doBlockLevels, which renders lists from lines starting with ':', '*', '#', etc.
Parser::replaceLinkHolders is called, which calls LinkHolderArray::replace on $Parser->mLinkHolders to replace link placeholders with actual links, in the buffer Placeholders created in Skin::makeLinkObj()
Next, the text is language converted (when applicable) using the convert method of the appropriate Language object.
Parser::replaceTransparentTags is called, which replaces transparent tags with values which are provided by the callback functions in $Parser->mTransparentTagHooks. Transparent tag hooks are like regular XML-style tag hooks, except they operate late in the transformation sequence, on HTML instead of wikitext.
Sanitizer::normalizeCharReferences is called, which ensures that any entities and character references are legal for XML and XHTML specifically.
If HTML tidy is enabled, MWTidy::tidy is called to do the tidying.
Finally the rendered HTML result of the parse process is stored in the ParserOutput object $Parser->mOutput, which is returned to the caller of Parser::parse.
Parser::setFunctionHook() Create a function, e.g. {{sum:1|2|3}} The callback function should have the form: function myParserFunction( &$parser, $arg1, $arg2, $arg3 ) { ... }
Parser::setFunctionTagHook() Create a tag function, e.g. <test>some stuff</test>. Unlike tag hooks, tag functions are parsed at preprocessor level. Unlike parser functions, their content is not preprocessed.
Parser::setHook() Create an HTML-style tag, e.g. <yourtag>special text</yourtag> The callback should have the following form: function myParserHook( $text, $params, $parser, $frame ) { ... }