MediaWiki REL1_35
Parser Class Reference

PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for making links), and provides a one-way transformation of that wiki markup it into (X)HTML output / markup (which in turn the browser understands, and can display). More...

Collaboration diagram for Parser:

Public Member Functions

 __clone ()
 Allow extensions to clean up when the parser is cloned.
 
 __construct ( $svcOptions=null, MagicWordFactory $magicWordFactory=null, Language $contLang=null, ParserFactory $factory=null, $urlProtocols=null, SpecialPageFactory $spFactory=null, $linkRendererFactory=null, $nsInfo=null, $logger=null, BadFileLookup $badFileLookup=null, LanguageConverterFactory $languageConverterFactory=null, HookContainer $hookContainer=null)
 Constructing parsers directly is deprecated! Use a ParserFactory.
 
 __destruct ()
 Reduce memory usage to reduce the impact of circular references.
 
 addTrackingCategory ( $msg)
 
 argSubstitution (array $piece, PPFrame $frame)
 Triple brace replacement – used for template arguments.
 
 attributeStripCallback (&$text, $frame=false)
 Callback from the Sanitizer for expanding items found in HTML attribute values, so they can be safely tested and escaped.
 
 braceSubstitution (array $piece, PPFrame $frame)
 Return the text of a template, after recursively replacing any variables or templates within the template.
 
 callParserFunction (PPFrame $frame, $function, array $args=[])
 Call a parser function and return an array with text and flags.
 
 cleanSig ( $text, $parsing=false)
 Clean up signature text.
 
 clearState ()
 Clear Parser state.
 
 clearTagHooks ()
 Remove all tag hooks.
 
 doBlockLevels ( $text, $linestart)
 Make lists from lines starting with ':', '*', '#', etc.
 
 doQuotes ( $text)
 Helper function for handleAllQuotes()
 
 enableOOUI ()
 Set's up the PHP implementation of OOUI for use in this request and instructs OutputPage to enable OOUI for itself.
 
 extensionSubstitution (array $params, PPFrame $frame)
 Return the text to be used for a given extension tag.
 
 fetchCurrentRevisionOfTitle (Title $title)
 Fetch the current revision of a given title.
 
 fetchCurrentRevisionRecordOfTitle (Title $title)
 Fetch the current revision of a given title as a RevisionRecord.
 
 fetchFileAndTitle (Title $title, array $options=[])
 Fetch a file and its title and register a reference to it.
 
 fetchTemplate (Title $title)
 Fetch the unparsed text of a template and register a reference to it.
 
 fetchTemplateAndTitle (Title $title)
 Fetch the unparsed text of a template and register a reference to it.
 
 firstCallInit ()
 Do various kinds of initialisation on the first call of the parser.
 
 getBadFileLookup ()
 Get the BadFileLookup instance that this Parser is using.
 
 getContentLanguage ()
 Get the content language that this Parser is using.
 
 getCustomDefaultSort ()
 Accessor for $mDefaultSort Unlike getDefaultSort(), will return false if none is set.
 
 getDefaultSort ()
 Accessor for $mDefaultSort Will use the empty string if none is set.
 
 getExternalLinkAttribs ( $url)
 Get an associative array of additional HTML attributes appropriate for a particular external link.
 
 getFlatSectionInfo ( $text)
 Get an array of preprocessor section information.
 
 getFreshParser ()
 Return this parser if it is not doing anything, otherwise get a fresh parser.
 
 getFunctionHooks ()
 Get all registered function hook identifiers.
 
 getFunctionLang ()
 Get a language object for use in parser functions such as {{FORMATNUM:}}.
 
 getFunctionSynonyms ()
 
 getLinkRenderer ()
 Get a LinkRenderer instance to make links with.
 
 getMagicWordFactory ()
 Get the MagicWordFactory that this Parser is using.
 
 getOptions ()
 
 getOutput ()
 
 getOutputType ()
 Accessor for the output type.
 
 getPreloadText ( $text, Title $title, ParserOptions $options, $params=[])
 Process the wikitext for the "?preload=" feature.
 
 getPreprocessor ()
 Get a preprocessor object.
 
 getRevisionId ()
 Get the ID of the revision we are parsing.
 
 getRevisionObject ()
 Get the revision object for $this->mRevisionId.
 
 getRevisionRecordObject ()
 Get the revision record object for $this->mRevisionId.
 
 getRevisionSize ()
 Get the size of the revision.
 
 getRevisionTimestamp ()
 Get the timestamp associated with the current revision, adjusted for the default server-local timestamp.
 
 getRevisionUser ()
 Get the name of the user that edited the last revision.
 
 getSection ( $text, $sectionId, $defaultText='')
 This function returns the text of a section, specified by a number ($section).
 
 getStripList ()
 Get a list of strippable XML-like elements.
 
 getStripState ()
 Get the StripState.
 
 getTags ()
 Accessor.
 
 getTargetLanguage ()
 Get the target language for the content being parsed.
 
 getTemplateDom (Title $title)
 Get the semi-parsed DOM representation of a template with a given title, and its redirect destination title.
 
 getTitle ()
 
 getUrlProtocols ()
 
 getUser ()
 Get a User object either from $this->mUser, if set, or from the ParserOptions object otherwise.
 
 getUserSig (User $user, $nickname=false, $fancySig=null)
 Fetch the user's signature text, if any, and normalize to validated, ready-to-insert wikitext.
 
 guessLegacySectionNameFromWikiText ( $text)
 Same as guessSectionNameFromWikiText(), but produces legacy anchors instead, if possible.
 
 guessSectionNameFromWikiText ( $text)
 Try to guess the section anchor name based on a wikitext fragment presumably extracted from a heading, for example "Header" from "== Header ==".
 
 incrementExpensiveFunctionCount ()
 Increment the expensive function count.
 
 insertStripItem ( $text)
 Add an item to the strip state Returns the unique tag which must be inserted into the stripped text The tag will be replaced with the original text in unstrip()
 
 internalParse ( $text, $isMain=true, $frame=false)
 Helper function for parse() that transforms wiki markup into half-parsed HTML.
 
 interwikiTransclude (Title $title, $action)
 Transclude an interwiki link.
 
 isCurrentRevisionOfTitleCached (Title $title)
 
 killMarkers ( $text)
 Remove any strip markers found in the given text.
 
 limitationWarn ( $limitationType, $current='', $max='')
 Warn the user when a parser limitation is reached Will warn at most once the user per limitation type.
 
 makeImage (Title $title, $options, $holders=false)
 Parse image options text and use it to make an image.
 
 markerSkipCallback ( $s, callable $callback)
 Call a callback function on all regions of the given text that are not inside strip markers, and replace those regions with the return value of the callback.
 
 nextLinkID ()
 
 Options ( $x=null)
 Accessor/mutator for the ParserOptions object.
 
 OutputType ( $x=null)
 Accessor/mutator for the output type.
 
 parse ( $text, Title $title, ParserOptions $options, $linestart=true, $clearState=true, $revid=null)
 Convert wikitext to HTML Do not call this function recursively.
 
 parseExtensionTagAsTopLevelDoc ( $text)
 Needed by Parsoid/PHP to ensure all the hooks for extensions are run in the right order.
 
 preprocess ( $text, ?Title $title, ParserOptions $options, $revid=null, $frame=false)
 Expand templates and variables in the text, producing valid, static wikitext.
 
 preprocessToDom ( $text, $flags=0)
 Preprocess some wikitext and return the document tree.
 
 preSaveTransform ( $text, Title $title, User $user, ParserOptions $options, $clearState=true)
 Transform wiki markup when saving a page by doing "\\r\\n" -> "\\n" conversion, substituting signatures, {{subst:}} templates, etc.
 
 recursivePreprocess ( $text, $frame=false)
 Recursive parser entry point that can be called from an extension tag hook.
 
 recursiveTagParse ( $text, $frame=false)
 Half-parse wikitext to half-parsed HTML.
 
 recursiveTagParseFully ( $text, $frame=false)
 Fully parse wikitext to fully parsed HTML.
 
 renderImageGallery ( $text, array $params)
 Renders an image gallery from a text with one line per image.
 
 replaceLinkHolders (&$text, $options=0)
 Replace "<!--LINK-->" link placeholders with actual links, in the buffer Placeholders created in Linker::link()
 
 replaceSection ( $oldText, $sectionId, $newText)
 This function returns $oldtext after the content of the section specified by $section has been replaced with $text.
 
 replaceVariables ( $text, $frame=false, $argsOnly=false)
 Replace magic variables, templates, and template arguments with the appropriate text.
 
 resetOutput ()
 Reset the ParserOutput.
 
 setDefaultSort ( $sort)
 Mutator for $mDefaultSort.
 
 setFunctionHook ( $id, callable $callback, $flags=0)
 Create a function, e.g.
 
 setFunctionTagHook ( $tag, callable $callback, $flags)
 Create a tag function, e.g.
 
 setHook ( $tag, callable $callback)
 Create an HTML-style tag, e.g.
 
 setLinkID ( $id)
 
 setOptions (ParserOptions $options)
 Mutator for the ParserOptions object.
 
 setOutputType ( $ot)
 Mutator for the output type.
 
 setTitle (Title $t=null)
 Set the context title.
 
 setUser (?User $user)
 Set the current user.
 
 startExternalParse (?Title $title, ParserOptions $options, $outputType, $clearState=true, $revId=null)
 Set up some variables which are usually set up in parse() so that an external function can call some class members with confidence.
 
 stripSectionName ( $text)
 Strips a text string of wikitext for use in a section anchor.
 
 Title (Title $x=null)
 Accessor/mutator for the Title object.
 
 transformMsg ( $text, ParserOptions $options, Title $title=null)
 Wrapper for preprocess()
 
 validateSig ( $text)
 Check that the user's signature contains no bad XML.
 

Static Public Member Functions

static cleanSigInSig ( $text)
 Strip 3, 4 or 5 tildes out of signatures.
 
static extractTagsAndParams (array $elements, $text, &$matches)
 Replaces all occurrences of HTML-style comments and the given tags in the text with a random marker and returns the next text.
 
static getExternalLinkRel ( $url=false, LinkTarget $title=null)
 Get the rel attribute for a particular external link.
 
static guessSectionNameFromStrippedText ( $text)
 Like guessSectionNameFromWikiText(), but takes already-stripped text as input.
 
static normalizeLinkUrl ( $url)
 Replace unusual escape codes in a URL with their equivalent characters.
 
static parseWidthParam ( $value, $parseHeight=true)
 Parsed a width param of imagelink like 300px or 200x300px.
 
static statelessFetchRevision (Title $title, $parser=false)
 Wrapper around Revision::newFromTitle to allow passing additional parameters without passing them on to it.
 
static statelessFetchRevisionRecord (Title $title, $parser=null)
 Wrapper around Revision::newFromTitle to allow passing additional parameters without passing them on to it.
 
static statelessFetchTemplate ( $title, $parser=false)
 Static function to get a template Can be overridden via ParserOptions::setTemplateCallback().
 
static stripOuterParagraph ( $html)
 Strip outer.
 

Public Attributes

 $mDoubleUnderscores
 
 $mExpensiveFunctionCount
 
bool $mFirstCall = true
 Whether firstCallInit still needs to be called.
 
 $mFunctionHooks = []
 
 $mGeneratedPPNodeCount
 
 $mHeadings
 
 $mHighestExpansionDepth
 
 $mIncludeSizes
 
bool string $mInParse = false
 Recursive call protection.
 
 $mInputSize = false
 
int $mLinkID
 
 $mMarkerIndex = 0
 
ParserOptions null $mOptions
 
ParserOutput $mOutput
 
 $mPPNodeCount
 
Preprocessor $mPreprocessor
 
 $mRevisionId
 
 $mRevisionObject
 
 $mRevisionSize
 
 $mRevisionTimestamp
 
 $mRevisionUser
 
 $mShowToc
 
StripState $mStripState
 
 $mTagHooks = []
 
Title null $mTitle
 Since 1.34, leaving mTitle uninitialized or setting mTitle to null is deprecated.
 
User $mUser
 
 $ot
 
const EXT_LINK_URL_CLASS = '[^][<>"\\x00-\\x20\\x7F\p{Zs}\x{FFFD}]'
 
const MARKER_PREFIX = "\x7f'\"`UNIQ-"
 
const OT_HTML = 1
 
const OT_MSG = 3
 
const OT_PLAIN = 4
 
const OT_PREPROCESS = 3
 
const OT_WIKI = 2
 
const PTD_FOR_INCLUSION = 1
 
const SFH_NO_HASH = 1
 
const SFH_OBJECT_ARGS = 2
 
const TOC_END = '</mw:toc>'
 
const TOC_START = '<mw:toc>'
 
const VERSION = '1.6.4'
 Update this version number when the ParserOutput format changes in an incompatible way, so the parser cache can automatically discard old data.
 

Protected Member Functions

 fetchFileNoRegister (Title $title, array $options=[])
 Helper function for fetchFileAndTitle.
 
 getHookContainer ()
 Get a HookContainer capable of returning metadata about hooks or running extension hooks.
 
 getHookRunner ()
 Get a HookRunner for calling core hooks.
 
 lock ()
 Lock the current instance of the parser.
 
 makeLimitReport ()
 Set the limit report data in the current ParserOutput, and return the limit report HTML comment.
 

Private Member Functions

 armorLinks ( $text)
 Insert a NOPARSE hacky thing into any inline links in a chunk that's going to go through further parsing steps before inline URL expansion.
 
 expandMagicVariable ( $index, $frame=false)
 Return value of a magic variable (like PAGENAME)
 
 extractSections ( $text, $sectionId, $mode, $newText='')
 Break wikitext input into sections, and either pull or replace some particular section's text.
 
 finalizeHeadings ( $text, $origText, $isMain=true)
 This function accomplishes several tasks: 1) Auto-number headings if that option is enabled 2) Add an [edit] link to sections for users who have enabled the option and can edit the page 3) Add a Table of contents on the top for users who have enabled the option 4) Auto-anchor headings.
 
 fuzzTestPreprocess ( $text, Title $title, ParserOptions $options)
 
 fuzzTestPst ( $text, Title $title, ParserOptions $options)
 
 fuzzTestSrvus ( $text, Title $title, ParserOptions $options, $outputType=self::OT_HTML)
 Strip/replaceVariables/unstrip for preprocessor regression testing.
 
 getContentLanguageConverter ()
 Shorthand for getting a Language Converter for Content language.
 
 getImageParams ( $handler)
 
 getTargetLanguageConverter ()
 Shorthand for getting a Language Converter for Target language.
 
 handleAllQuotes ( $text)
 Replace single quotes with HTML markup.
 
 handleDoubleUnderscore ( $text)
 Strip double-underscore items like NOGALLERY and NOTOC Fills $this->mDoubleUnderscores, returns the modified text.
 
 handleExternalLinks ( $text)
 Replace external links (REL)
 
 handleHeadings ( $text)
 Parse headers and return html.
 
 handleInternalLinks ( $text)
 Process [[ ]] wikilinks.
 
 handleInternalLinks2 (&$s)
 Process [[ ]] wikilinks (RIL)
 
 handleMagicLinks ( $text)
 Replace special strings like "ISBN xxx" and "RFC xxx" with magic external links.
 
 handleTables ( $text)
 Parse the wiki syntax used to render tables.
 
 incrementIncludeSize ( $type, $size)
 Increment an include size counter.
 
 initializeVariables ()
 Initialize the magic variables (like CURRENTMONTHNAME) and substitution modifiers.
 
 internalParseHalfParsed ( $text, $isMain=true, $linestart=true)
 Helper function for parse() that transforms half-parsed HTML into fully parsed HTML.
 
 magicLinkCallback (array $m)
 
 makeFreeExternalLink ( $url, $numPostProto)
 Make a free external link, given a user-supplied URL.
 
 makeKnownLinkHolder (Title $nt, $text='', $trail='', $prefix='')
 Render a forced-blue link inline; protect against double expansion of URLs if we're in a mode that prepends full URL prefixes to internal links.
 
 makeLegacyAnchor ( $sectionName)
 
 maybeMakeExternalImage ( $url)
 make an image if it's allowed, either through the global option, through the exception, or through the on-wiki whitelist
 
 parseLinkParameter ( $value)
 Parse the value of 'link' parameter in image syntax ([[File:Foo.jpg|link=<value>]]).
 
 pstPass2 ( $text, User $user)
 Pre-save transform helper function.
 
 replaceLinkHoldersPrivate (&$text, $options=0)
 Replace "<!--LINK-->" link placeholders with actual links, in the buffer Placeholders created in Linker::link()
 
 replaceLinkHoldersText ( $text)
 Replace "<!--LINK-->" link placeholders with plain text of links (not HTML-formatted).
 
 setOutputFlag (string $flag, string $reason)
 Sets the flag on the parser output but also does some debug logging.
 
 startParse (?Title $title, ParserOptions $options, $outputType, $clearState=true)
 
 stripAltText ( $caption, $holders)
 

Static Private Member Functions

static getSectionNameFromStrippedText ( $text)
 
static makeAnchor ( $sectionName)
 
static normalizeSectionName ( $text)
 Apply the same normalization as code making links to this section would.
 
static normalizeUrlComponent ( $component, $unsafe)
 

Private Attributes

BadFileLookup $badFileLookup
 
Language $contLang
 
MapCacheLRU null $currentRevisionCache
 
ParserFactory $factory
 
HookContainer $hookContainer
 
HookRunner $hookRunner
 
LanguageConverterFactory $languageConverterFactory
 
LinkRendererFactory $linkRendererFactory
 
LoggerInterface $logger
 
MagicWordFactory $magicWordFactory
 
 $mAutonumber
 
array $mConf
 
 $mDefaultSort
 
 $mExtLinkBracketedRegex
 
 $mForceTocPosition
 
 $mFunctionSynonyms = [ 0 => [], 1 => [] ]
 
 $mFunctionTagHooks = []
 
 $mImageParams = []
 
 $mImageParamsMagicArray = []
 
array $mLangLinkLanguages
 Array with the language name of each language link (i.e.
 
LinkHolderArray $mLinkHolders
 
LinkRenderer $mLinkRenderer
 
 $mOutputType
 
SectionProfiler $mProfiler
 
RevisionRecord null $mRevisionRecordObject
 
 $mStripList = []
 
MagicWordArray $mSubstWords
 
array $mTplDomCache
 
 $mTplRedirCache
 
 $mUrlProtocols
 
 $mVarCache = []
 
MagicWordArray $mVariables
 
NamespaceInfo $nsInfo
 
SpecialPageFactory $specialPageFactory
 
ServiceOptions $svcOptions
 This is called $svcOptions instead of $options like elsewhere to avoid confusion with $mOptions, which is public and widely used, and also with the local variable $options used for ParserOptions throughout this file.
 
const EXT_IMAGE_REGEX
 
const EXT_LINK_ADDR = '(?:[0-9.]+|\\[(?i:[0-9a-f:.]+)\\]|[^][<>"\\x00-\\x20\\x7F\p{Zs}\x{FFFD}])'
 
const SPACE_NOT_NL = '(?:\t|&nbsp;|&\#0*160;|&\#[Xx]0*[Aa]0;|\p{Zs})'
 

Detailed Description

PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for making links), and provides a one-way transformation of that wiki markup it into (X)HTML output / markup (which in turn the browser understands, and can display).

There are seven main entry points into the Parser class:

  • Parser::parse() produces HTML output
  • Parser::preSaveTransform() produces altered wiki markup
  • Parser::preprocess() removes HTML comments and expands templates
  • Parser::cleanSig() and Parser::cleanSigInSig() cleans a signature before saving it to preferences
  • Parser::getSection() return the content of a section from an article for section editing
  • Parser::replaceSection() replaces a section by number inside an article
  • Parser::getPreloadText() removes <noinclude> sections and <includeonly> tags
Warning
$wgUser or $wgTitle or $wgRequest or $wgLang. Keep them away!
Settings:
$wgNamespacesWithSubpages
Settings only within ParserOptions:
$wgAllowExternalImages $wgAllowSpecialInclusion $wgInterwikiMagic $wgMaxArticleSize

Definition at line 85 of file Parser.php.

Constructor & Destructor Documentation

◆ __construct()

Parser::__construct (   $svcOptions = null,
MagicWordFactory  $magicWordFactory = null,
Language  $contLang = null,
ParserFactory  $factory = null,
  $urlProtocols = null,
SpecialPageFactory  $spFactory = null,
  $linkRendererFactory = null,
  $nsInfo = null,
  $logger = null,
BadFileLookup  $badFileLookup = null,
LanguageConverterFactory  $languageConverterFactory = null,
HookContainer  $hookContainer = null 
)

Constructing parsers directly is deprecated! Use a ParserFactory.

Definition at line 406 of file Parser.php.

References MediaWiki\Config\ServiceOptions\assertRequiredOptions(), firstCallInit(), MediaWiki\Config\ServiceOptions\get(), wfDeprecated(), and wfUrlProtocols().

◆ __destruct()

Parser::__destruct ( )

Reduce memory usage to reduce the impact of circular references.

Definition at line 484 of file Parser.php.

Member Function Documentation

◆ __clone()

Parser::__clone ( )

Allow extensions to clean up when the parser is cloned.

Definition at line 498 of file Parser.php.

◆ addTrackingCategory()

Parser::addTrackingCategory (   $msg)
See also
ParserOutput::addTrackingCategory()
Parameters
string$msgMessage key
Returns
bool Whether the addition was successful

Definition at line 4056 of file Parser.php.

References getTitle().

◆ argSubstitution()

Parser::argSubstitution ( array  $piece,
PPFrame  $frame 
)

Triple brace replacement – used for template arguments.

Definition at line 3827 of file Parser.php.

References PPFrame\expand(), PPFrame\getArgument(), PPFrame\isTemplate(), and PPFrame\virtualBracketedImplode().

◆ armorLinks()

Parser::armorLinks (   $text)
private

Insert a NOPARSE hacky thing into any inline links in a chunk that's going to go through further parsing steps before inline URL expansion.

Not needed quite as much as it used to be since free links are a bit more sensible these days. But bracketed links are still an issue.

Parameters
string$textMore-or-less HTML
Returns
string Less-or-more HTML with NOPARSE bits

Definition at line 2732 of file Parser.php.

◆ attributeStripCallback()

Parser::attributeStripCallback ( $text,
  $frame = false 
)

Callback from the Sanitizer for expanding items found in HTML attribute values, so they can be safely tested and escaped.

Parameters
string&$text
bool | PPFrame$frame
Returns
string
Deprecated:
since 1.35, internal callback should not have been public

Definition at line 5509 of file Parser.php.

References wfDeprecated().

◆ braceSubstitution()

Parser::braceSubstitution ( array  $piece,
PPFrame  $frame 
)

Return the text of a template, after recursively replacing any variables or templates within the template.

Parameters
array$pieceThe parts of the template $piece['title']: the title, i.e. the part before the | $piece['parts']: the parameter array $piece['lineStart']: whether the brace was at the start of a line
PPFrame$frameThe current frame, contains template arguments
Exceptions
Exception
Returns
string|array The text of the template

Definition at line 2941 of file Parser.php.

References $args, $title, PPFrame\expand(), getTitle(), getUser(), PPFrame\loopCheck(), PPFrame\newChild(), User\newFromName(), Linker\normalizeSubpageLink(), NS_TEMPLATE, RequestContext\setTitle(), PPFrame\virtualBracketedImplode(), wfEscapeWikiText(), and wfMessage().

◆ callParserFunction()

Parser::callParserFunction ( PPFrame  $frame,
  $function,
array  $args = [] 
)

Call a parser function and return an array with text and flags.

The returned array will always contain a boolean 'found', indicating whether the parser function was found or not. It may also contain the following: text: string|object, resulting wikitext or PP DOM object isHTML: bool, $text is HTML, armour it against wikitext transformation isChildObj: bool, $text is a DOM node needing expansion in a child frame isLocalObj: bool, $text is a DOM node needing expansion in the current frame nowiki: bool, wiki markup in $text should be escaped

Since
1.21
Parameters
PPFrame$frameThe current frame, contains template arguments
string$functionFunction name
array$argsArguments to the function
Returns
array

Definition at line 3295 of file Parser.php.

References $args, and PPFrame\expand().

◆ cleanSig()

Parser::cleanSig (   $text,
  $parsing = false 
)

Clean up signature text.

1) Strip 3, 4 or 5 tildes out of signatures

See also
cleanSigInSig 2) Substitute all transclusions
Parameters
string$text
bool$parsingWhether we're cleaning (preferences save) or parsing
Returns
string Signature text

Definition at line 4667 of file Parser.php.

References $wgTitle.

◆ cleanSigInSig()

static Parser::cleanSigInSig (   $text)
static

Strip 3, 4 or 5 tildes out of signatures.

Parameters
string$text
Returns
string Signature text with /~{3,5}/ removed

Definition at line 4704 of file Parser.php.

◆ clearState()

Parser::clearState ( )

Clear Parser state.

Definition at line 541 of file Parser.php.

References firstCallInit(), getContentLanguageConverter(), getHookContainer(), and resetOutput().

◆ clearTagHooks()

Parser::clearTagHooks ( )

Remove all tag hooks.

Definition at line 4814 of file Parser.php.

◆ doBlockLevels()

Parser::doBlockLevels (   $text,
  $linestart 
)

Make lists from lines starting with ':', '*', '#', etc.

(DBL)

Parameters
string$text
bool$linestartWhether or not this is at the start of a line.

Definition at line 2746 of file Parser.php.

References BlockLevelPass\doBlockLevels(), and wfDeprecated().

◆ doQuotes()

Parser::doQuotes (   $text)

Helper function for handleAllQuotes()

Parameters
string$text
Returns
string

Definition at line 1927 of file Parser.php.

◆ enableOOUI()

Parser::enableOOUI ( )

Set's up the PHP implementation of OOUI for use in this request and instructs OutputPage to enable OOUI for itself.

Since
1.26
Deprecated:
since 1.35, use $parser->getOutput()->enableOOUI() instead.

Definition at line 6301 of file Parser.php.

References wfDeprecated().

◆ expandMagicVariable()

Parser::expandMagicVariable (   $index,
  $frame = false 
)
private

Return value of a magic variable (like PAGENAME)

Parameters
string$indexMagic variable identifier as mapped in MagicWordFactory::$mVariableIDs
bool | PPFrame$frame
Returns
string

Definition at line 2759 of file Parser.php.

References CoreMagicVariables\expand(), wfDeprecatedMsg(), and wfTimestamp().

◆ extensionSubstitution()

Parser::extensionSubstitution ( array  $params,
PPFrame  $frame 
)

Return the text to be used for a given extension tag.

This is the ghost of strip().

Parameters
array$paramsAssociative array of parameters: name PPNode for the tag name attr PPNode for unparsed text where tag attributes are thought to be attributes Optional associative array of parsed attributes inner Contents of extension element noClose Original text did not have a close tag
PPFrame$frame
Exceptions
MWException
Returns
string

Definition at line 3880 of file Parser.php.

References $content, and PPFrame\expand().

◆ extractSections()

Parser::extractSections (   $text,
  $sectionId,
  $mode,
  $newText = '' 
)
private

Break wikitext input into sections, and either pull or replace some particular section's text.

External callers should use the getSection and replaceSection methods.

Parameters
string$textPage wikitext
string | int$sectionIdA section identifier string of the form: "<flag1> - <flag2> - ... - <section number>"

Currently the only recognised flag is "T", which means the target section number was derived during a template inclusion parse, in other words this is a template section edit link. If no flags are given, it was an ordinary section edit link. This flag is required to avoid a section numbering mismatch when a section is enclosed by "<includeonly>" (T8563).

The section number 0 pulls the text before the first heading; other numbers will pull the given section along with its lower-level subsections. If the section is not found, $mode=get will return $newtext, and $mode=replace will return $text.

Section 0 is always considered to exist, even if it only contains the empty string. If $text is the empty string and section 0 is replaced, $newText is returned.

Parameters
string$modeOne of "get" or "replace"
string$newTextReplacement text for section data.
Returns
string For "get", the extracted section text. for "replace", the whole page with the section replaced.

Definition at line 5575 of file Parser.php.

References $wgTitle.

◆ extractTagsAndParams()

static Parser::extractTagsAndParams ( array  $elements,
  $text,
$matches 
)
static

Replaces all occurrences of HTML-style comments and the given tags in the text with a random marker and returns the next text.

The output parameter $matches will be an associative array filled with data in the form:

'UNIQ-xxxxx' => [
'element',
'tag content',
[ 'param' => 'x' ],
'<element param="x">tag content</element>' ]
Parameters
array$elementsList of element names. Comments are always extracted.
string$textSource text string.
array&$matchesOut parameter, Array: extracted tags
Returns
string Stripped text

Definition at line 1228 of file Parser.php.

References $content, and $matches.

◆ fetchCurrentRevisionOfTitle()

Parser::fetchCurrentRevisionOfTitle ( Title  $title)

Fetch the current revision of a given title.

Note that the revision (and even the title) may not exist in the database, so everything contributing to the output of the parser should use this method where possible, rather than getting the revisions themselves. This method also caches its results, so using it benefits performance.

This can return false if the callback returns false

Deprecated:
since 1.35, use fetchCurrentRevisionRecordOfTitle instead
Since
1.24
Parameters
Title$title
Returns
Revision|false

Definition at line 3430 of file Parser.php.

References $title, and wfDeprecated().

◆ fetchCurrentRevisionRecordOfTitle()

Parser::fetchCurrentRevisionRecordOfTitle ( Title  $title)

Fetch the current revision of a given title as a RevisionRecord.

Note that the revision (and even the title) may not exist in the database, so everything contributing to the output of the parser should use this method where possible, rather than getting the revisions themselves. This method also caches its results, so using it benefits performance.

This can return null if the callback returns false

Since
1.35
Parameters
Title$title
Returns
RevisionRecord|null

Definition at line 3452 of file Parser.php.

References $title.

◆ fetchFileAndTitle()

Parser::fetchFileAndTitle ( Title  $title,
array  $options = [] 
)

Fetch a file and its title and register a reference to it.

If 'broken' is a key in $options then the file will appear as a broken thumbnail.

Parameters
Title$title
array$optionsArray of options to RepoGroup::findFile
Returns
array ( File or false, Title of file )

Definition at line 3710 of file Parser.php.

References $file, and $title.

◆ fetchFileNoRegister()

Parser::fetchFileNoRegister ( Title  $title,
array  $options = [] 
)
protected

Helper function for fetchFileAndTitle.

Also useful if you need to fetch a file but not use it yet, for example to get the file's handler.

Parameters
Title$title
array$optionsArray of options to RepoGroup::findFile
Returns
File|bool

Definition at line 3735 of file Parser.php.

References $file, and $title.

◆ fetchTemplate()

Parser::fetchTemplate ( Title  $title)

Fetch the unparsed text of a template and register a reference to it.

Parameters
Title$title
Returns
string|bool
Deprecated:
since 1.35, use Parser::fetchTemplateAndTitle(...)[0]

Definition at line 3572 of file Parser.php.

References $title, and wfDeprecated().

◆ fetchTemplateAndTitle()

Parser::fetchTemplateAndTitle ( Title  $title)

Fetch the unparsed text of a template and register a reference to it.

Parameters
Title$title
Returns
array ( string or false, Title )

Definition at line 3527 of file Parser.php.

References $title, and getTitle().

◆ finalizeHeadings()

Parser::finalizeHeadings (   $text,
  $origText,
  $isMain = true 
)
private

This function accomplishes several tasks: 1) Auto-number headings if that option is enabled 2) Add an [edit] link to sections for users who have enabled the option and can edit the page 3) Add a Table of contents on the top for users who have enabled the option 4) Auto-anchor headings.

It loops through all headlines, collects the necessary data, then splits up the string and re-inserts the newly formatted headlines.

Parameters
string$text
string$origTextOriginal, untouched wikitext
bool$isMain
Returns
mixed|string

Definition at line 4075 of file Parser.php.

References $matches, getTitle(), Linker\makeHeadline(), Linker\tocIndent(), Linker\tocLine(), Linker\tocLineEnd(), Linker\tocList(), and Linker\tocUnindent().

◆ firstCallInit()

Parser::firstCallInit ( )

Do various kinds of initialisation on the first call of the parser.

Deprecated:
since 1.35, this initialization is done in the constructor and manual calls to ::firstCallInit() have no effect.

Definition at line 523 of file Parser.php.

References initializeVariables(), CoreParserFunctions\register(), and CoreTagHooks\register().

Referenced by __construct(), and clearState().

◆ fuzzTestPreprocess()

Parser::fuzzTestPreprocess (   $text,
Title  $title,
ParserOptions  $options 
)
private
Parameters
string$text
Title$title
ParserOptions$options
Returns
string

Definition at line 6145 of file Parser.php.

References $title.

◆ fuzzTestPst()

Parser::fuzzTestPst (   $text,
Title  $title,
ParserOptions  $options 
)
private
Parameters
string$text
Title$title
ParserOptions$options
Returns
string

Definition at line 6135 of file Parser.php.

References $title, and ParserOptions\getUser().

◆ fuzzTestSrvus()

Parser::fuzzTestSrvus (   $text,
Title  $title,
ParserOptions  $options,
  $outputType = self::OT_HTML 
)
private

Strip/replaceVariables/unstrip for preprocessor regression testing.

Parameters
string$text
Title$title
ParserOptions$options
int$outputType
Returns
string

Definition at line 6117 of file Parser.php.

References $title.

◆ getBadFileLookup()

Parser::getBadFileLookup ( )

Get the BadFileLookup instance that this Parser is using.

Since
1.35
Returns
BadFileLookup

Definition at line 1205 of file Parser.php.

Referenced by Linker\makeImageLink().

◆ getContentLanguage()

Parser::getContentLanguage ( )

Get the content language that this Parser is using.

Since
1.32
Returns
Language

Definition at line 1195 of file Parser.php.

Referenced by CoreMagicVariables\expand(), and CoreMagicVariables\getRevisionTimestampSubstring().

◆ getContentLanguageConverter()

Parser::getContentLanguageConverter ( )
private

Shorthand for getting a Language Converter for Content language.

Returns
ILanguageConverter

Definition at line 1616 of file Parser.php.

Referenced by clearState().

◆ getCustomDefaultSort()

Parser::getCustomDefaultSort ( )

Accessor for $mDefaultSort Unlike getDefaultSort(), will return false if none is set.

Returns
string|bool

Definition at line 5986 of file Parser.php.

◆ getDefaultSort()

Parser::getDefaultSort ( )

Accessor for $mDefaultSort Will use the empty string if none is set.

This value is treated as a prefix, so the empty string is equivalent to sorting by page name.

Returns
string

Definition at line 5972 of file Parser.php.

◆ getExternalLinkAttribs()

Parser::getExternalLinkAttribs (   $url)

Get an associative array of additional HTML attributes appropriate for a particular external link.

This currently may include rel => nofollow (depending on configuration, namespace, and the URL's domain) and/or a target attribute (depending on configuration).

Definition at line 2212 of file Parser.php.

References getTitle().

◆ getExternalLinkRel()

static Parser::getExternalLinkRel (   $url = false,
LinkTarget  $title = null 
)
static

Get the rel attribute for a particular external link.

Since
1.21

Definition at line 2190 of file Parser.php.

References $title, $wgNoFollowDomainExceptions, $wgNoFollowLinks, $wgNoFollowNsExceptions, and wfMatchesDomainList().

◆ getFlatSectionInfo()

Parser::getFlatSectionInfo (   $text)

Get an array of preprocessor section information.

Preprocessor sections are those identified by wikitext-style syntax, not HTML-style syntax. Templates are not expanded, so these sections do not include sections created by templates or parser functions. This is the same definition of a section as used by section editing, but not the same as TOC generation.

These sections are typically smaller than those acted on by getSection() and replaceSection() since they are not nested. Section nesting could be reconstructed from the heading levels.

The return value is an array of associative array info structures. Each associative array contains the following keys, describing a section:

  • index: An integer identifying the section.
  • level: The heading level, e.g. 1 for

    . For the section before the the first heading, this will be 0..offset: The byte offset within the wikitext at which the section startsstartsheading: The wikitext for the header which introduces the section, including equals signs. For the section before the first heading, this will be an empty string..text: The complete text of the section. @param string $text @return array[]

Definition at line 5750 of file Parser.php.

◆ getFreshParser()

Parser::getFreshParser ( )

Return this parser if it is not doing anything, otherwise get a fresh parser.

You can use this method by doing $newParser = $oldParser->getFreshParser(), or more simply $oldParser->getFreshParser()->parse( ... ); if you're unsure if $oldParser is safe to use.

Since
1.24
Returns
Parser A parser object that is not parsing anything

Definition at line 6286 of file Parser.php.

◆ getFunctionHooks()

Parser::getFunctionHooks ( )

Get all registered function hook identifiers.

Returns
array

Definition at line 4899 of file Parser.php.

◆ getFunctionLang()

Parser::getFunctionLang ( )

Get a language object for use in parser functions such as {{FORMATNUM:}}.

Returns
Language

Definition at line 1112 of file Parser.php.

◆ getFunctionSynonyms()

Parser::getFunctionSynonyms ( )
Since
1.32
Returns
array

Definition at line 5533 of file Parser.php.

◆ getHookContainer()

Parser::getHookContainer ( )
protected

Get a HookContainer capable of returning metadata about hooks or running extension hooks.

Since
1.35
Returns
HookContainer

Definition at line 1629 of file Parser.php.

Referenced by clearState().

◆ getHookRunner()

Parser::getHookRunner ( )
protected

Get a HookRunner for calling core hooks.

Definition at line 1641 of file Parser.php.

◆ getImageParams()

Parser::getImageParams (   $handler)
private
Parameters
MediaHandler | false$handler
Returns
array

Definition at line 5141 of file Parser.php.

References $type.

◆ getLinkRenderer()

Parser::getLinkRenderer ( )

Get a LinkRenderer instance to make links with.

Since
1.28
Returns
LinkRenderer

Definition at line 1167 of file Parser.php.

◆ getMagicWordFactory()

Parser::getMagicWordFactory ( )

Get the MagicWordFactory that this Parser is using.

Since
1.32
Returns
MagicWordFactory

Definition at line 1185 of file Parser.php.

◆ getOptions()

Parser::getOptions ( )
Returns
ParserOptions|null

Definition at line 1069 of file Parser.php.

Referenced by CoreMagicVariables\expand().

◆ getOutput()

Parser::getOutput ( )

◆ getOutputType()

Parser::getOutputType ( )

Accessor for the output type.

Returns
int One of the Parser::OT_... constants
Since
1.35

Definition at line 1028 of file Parser.php.

◆ getPreloadText()

Parser::getPreloadText (   $text,
Title  $title,
ParserOptions  $options,
  $params = [] 
)

Process the wikitext for the "?preload=" feature.

(T7210)

"<noinclude>", "<includeonly>" etc. are parsed as for template transclusion, comments, templates, arguments, tags hooks and parser functions are untouched.

Parameters
string$text
Title$title
ParserOptions$options
array$params
Returns
string

Definition at line 961 of file Parser.php.

References $title, getPreprocessor(), lock(), preprocessToDom(), and startParse().

◆ getPreprocessor()

Parser::getPreprocessor ( )

Get a preprocessor object.

Returns
Preprocessor

Definition at line 1154 of file Parser.php.

Referenced by getPreloadText().

◆ getRevisionId()

Parser::getRevisionId ( )

Get the ID of the revision we are parsing.

The return value will be either:

  • a) Positive, indicating a specific revision ID (current or old)
  • b) Zero, meaning the revision ID is specified by getCurrentRevisionRecordCallback()
  • c) Null, meaning the parse is for preview mode and there is no revision
Returns
int|null

Definition at line 5798 of file Parser.php.

Referenced by CoreMagicVariables\expand().

◆ getRevisionObject()

Parser::getRevisionObject ( )

Get the revision object for $this->mRevisionId.

Deprecated:
since 1.35, use getRevisionRecordObject
Returns
Revision|null Either a Revision object or null
Since
1.23 (public since 1.23)

Definition at line 5809 of file Parser.php.

References wfDeprecated().

◆ getRevisionRecordObject()

Parser::getRevisionRecordObject ( )

Get the revision record object for $this->mRevisionId.

Returns
RevisionRecord|null Either a RevisionRecord object or null
Since
1.35

Definition at line 5832 of file Parser.php.

Referenced by CoreMagicVariables\expand().

◆ getRevisionSize()

Parser::getRevisionSize ( )

Get the size of the revision.

Returns
int|null Revision size

Definition at line 5936 of file Parser.php.

Referenced by CoreMagicVariables\expand().

◆ getRevisionTimestamp()

Parser::getRevisionTimestamp ( )

Get the timestamp associated with the current revision, adjusted for the default server-local timestamp.

Returns
string TS_MW timestamp

Definition at line 5886 of file Parser.php.

◆ getRevisionUser()

Parser::getRevisionUser ( )

Get the name of the user that edited the last revision.

Returns
string|null User name

Definition at line 5913 of file Parser.php.

References getUser().

Referenced by CoreMagicVariables\expand().

◆ getSection()

Parser::getSection (   $text,
  $sectionId,
  $defaultText = '' 
)

This function returns the text of a section, specified by a number ($section).

A section is text under a heading like == Heading == or \<h1\>Heading\</h1\>, or the first section before any such heading (section 0).

If a section contains subsections, these are also returned.

Parameters
string$textText to look in
string | int$sectionIdSection identifier as a number or string (e.g. 0, 1 or 'T-1').
string$defaultTextDefault to return if section is not found
Returns
string Text of the requested section

Definition at line 5701 of file Parser.php.

◆ getSectionNameFromStrippedText()

static Parser::getSectionNameFromStrippedText (   $text)
staticprivate

Definition at line 5990 of file Parser.php.

◆ getStripList()

Parser::getStripList ( )

Get a list of strippable XML-like elements.

Returns
array

Definition at line 1291 of file Parser.php.

◆ getStripState()

Parser::getStripState ( )

Get the StripState.

Returns
StripState

Definition at line 1300 of file Parser.php.

◆ getTags()

Parser::getTags ( )

Accessor.

Returns
array

Definition at line 5521 of file Parser.php.

◆ getTargetLanguage()

Parser::getTargetLanguage ( )

Get the target language for the content being parsed.

This is usually the language that the content is in.

Since
1.19
Returns
Language

Definition at line 1124 of file Parser.php.

References getTitle().

Referenced by LinkHolderArray\__construct(), and Linker\makeImageLink().

◆ getTargetLanguageConverter()

Parser::getTargetLanguageConverter ( )
private

Shorthand for getting a Language Converter for Target language.

Returns
ILanguageConverter

Definition at line 1605 of file Parser.php.

Referenced by parse().

◆ getTemplateDom()

Parser::getTemplateDom ( Title  $title)

Get the semi-parsed DOM representation of a template with a given title, and its redirect destination title.

Cached.

Parameters
Title$title
Returns
array

Definition at line 3384 of file Parser.php.

References $title.

◆ getTitle()

Parser::getTitle ( )
Returns
Title|null

Definition at line 1007 of file Parser.php.

Referenced by Linker\makeImageLink().

◆ getUrlProtocols()

Parser::getUrlProtocols ( )
Since
1.32
Returns
string

Definition at line 5542 of file Parser.php.

◆ getUser()

Parser::getUser ( )

Get a User object either from $this->mUser, if set, or from the ParserOptions object otherwise.

Returns
User

Definition at line 1142 of file Parser.php.

◆ getUserSig()

Parser::getUserSig ( User  $user,
  $nickname = false,
  $fancySig = null 
)

Fetch the user's signature text, if any, and normalize to validated, ready-to-insert wikitext.

If you have pre-fetched the nickname or the fancySig option, you can specify them here to save a database query. Do not reuse this parser instance after calling getUserSig(), as it may have changed.

Parameters
User$user
string | false$nicknameNickname to use or false to use user's default nickname
bool | null$fancySigwhether the nicknname is the complete signature or null to use default value
Returns
string

Definition at line 4593 of file Parser.php.

References User\getBoolOption(), User\getName(), User\getOption(), getTitle(), User\isAnon(), wfEscapeWikiText(), and wfMessage().

◆ guessLegacySectionNameFromWikiText()

Parser::guessLegacySectionNameFromWikiText (   $text)

Same as guessSectionNameFromWikiText(), but produces legacy anchors instead, if possible.

For use in redirects, since various versions of Microsoft browsers interpret Location: headers as something other than UTF-8, resulting in breakage.

Parameters
string$textThe section name
Returns
string Anchor (starting with '#')

Definition at line 6037 of file Parser.php.

◆ guessSectionNameFromStrippedText()

static Parser::guessSectionNameFromStrippedText (   $text)
static

Like guessSectionNameFromWikiText(), but takes already-stripped text as input.

Parameters
string$textSection name (plain text)
Returns
string Anchor (starting with '#')

Definition at line 6049 of file Parser.php.

◆ guessSectionNameFromWikiText()

Parser::guessSectionNameFromWikiText (   $text)

Try to guess the section anchor name based on a wikitext fragment presumably extracted from a heading, for example "Header" from "== Header ==".

Parameters
string$text
Returns
string Anchor (starting with '#')

Definition at line 6021 of file Parser.php.

◆ handleAllQuotes()

Parser::handleAllQuotes (   $text)
private

Replace single quotes with HTML markup.

Parameters
string$text
Returns
string The altered text

Definition at line 1909 of file Parser.php.

References $line, $lines, and StringUtils\explode().

◆ handleDoubleUnderscore()

Parser::handleDoubleUnderscore (   $text)
private

Strip double-underscore items like NOGALLERY and NOTOC Fills $this->mDoubleUnderscores, returns the modified text.

Parameters
string$text
Returns
string

Definition at line 4003 of file Parser.php.

References getTitle(), and NS_CATEGORY.

◆ handleExternalLinks()

Parser::handleExternalLinks (   $text)
private

Replace external links (REL)

Note: this is all very hackish and the order of execution matters a lot. Make sure to run tests/parser/parserTests.php if you change this code.

Parameters
string$text
Exceptions
MWException
Returns
string

Definition at line 2110 of file Parser.php.

References $s, getTitle(), Linker\makeExternalLink(), Linker\splitTrail(), and wfUrlProtocolsWithoutProtRel().

◆ handleHeadings()

Parser::handleHeadings (   $text)
private

Parse headers and return html.

Parameters
string$text
Returns
string

Definition at line 1892 of file Parser.php.

◆ handleInternalLinks()

Parser::handleInternalLinks (   $text)
private

Process [[ ]] wikilinks.

Parameters
string$text
Returns
string Processed text

Definition at line 2381 of file Parser.php.

◆ handleInternalLinks2()

Parser::handleInternalLinks2 ( $s)
private

Process [[ ]] wikilinks (RIL)

Parameters
string&$s
Returns
LinkHolderArray

Definition at line 2391 of file Parser.php.

References $file, $line, $s, StringUtils\explode(), getTitle(), Linker\makeMediaLinkFile(), Linker\makeSelfLinkObj(), Linker\normalizeSubpageLink(), NS_CATEGORY, NS_FILE, NS_MEDIA, and NS_SPECIAL.

◆ handleMagicLinks()

Parser::handleMagicLinks (   $text)
private

Replace special strings like "ISBN xxx" and "RFC xxx" with magic external links.

DML

Parameters
string$text
Returns
string

Definition at line 1710 of file Parser.php.

References wfUrlProtocolsWithoutProtRel().

◆ handleTables()

Parser::handleTables (   $text)
private

Parse the wiki syntax used to render tables.

Parameters
string$text
Returns
string

Definition at line 1326 of file Parser.php.

References $line, $lines, $matches, StringUtils\explode(), and StringUtils\replaceMarkup().

◆ incrementExpensiveFunctionCount()

Parser::incrementExpensiveFunctionCount ( )

Increment the expensive function count.

Returns
bool False if the limit has been exceeded

Definition at line 3991 of file Parser.php.

◆ incrementIncludeSize()

Parser::incrementIncludeSize (   $type,
  $size 
)
private

Increment an include size counter.

Parameters
string$typeThe type of expansion
int$sizeThe size of the text
Returns
bool False if this inclusion would take it over the maximum, true otherwise

Definition at line 3977 of file Parser.php.

References $type.

◆ initializeVariables()

Parser::initializeVariables ( )
private

Initialize the magic variables (like CURRENTMONTHNAME) and substitution modifiers.

Definition at line 2812 of file Parser.php.

Referenced by firstCallInit().

◆ insertStripItem()

Parser::insertStripItem (   $text)

Add an item to the strip state Returns the unique tag which must be inserted into the stripped text The tag will be replaced with the original text in unstrip()

Parameters
string$text
Returns
string

Definition at line 1313 of file Parser.php.

◆ internalParse()

Parser::internalParse (   $text,
  $isMain = true,
  $frame = false 
)

Helper function for parse() that transforms wiki markup into half-parsed HTML.

Only called for $mOutputType == self::OT_HTML.

Definition at line 1536 of file Parser.php.

Referenced by parse(), and recursiveTagParse().

◆ internalParseHalfParsed()

Parser::internalParseHalfParsed (   $text,
  $isMain = true,
  $linestart = true 
)
private

Helper function for parse() that transforms half-parsed HTML into fully parsed HTML.

Parameters
string$text
bool$isMain
bool$linestart
Returns
string

Definition at line 1654 of file Parser.php.

References BlockLevelPass\doBlockLevels(), and MWTidy\tidy().

Referenced by parse(), parseExtensionTagAsTopLevelDoc(), and recursiveTagParseFully().

◆ interwikiTransclude()

Parser::interwikiTransclude ( Title  $title,
  $action 
)

Transclude an interwiki link.

Parameters
Title$title
string$actionUsually one of (raw, render)
Returns
string

Definition at line 3758 of file Parser.php.

References $cache, $title, and wfMessage().

◆ isCurrentRevisionOfTitleCached()

Parser::isCurrentRevisionOfTitleCached ( Title  $title)
Parameters
Title$title
Returns
bool
Since
1.34

Definition at line 3481 of file Parser.php.

References $title.

◆ killMarkers()

Parser::killMarkers (   $text)

Remove any strip markers found in the given text.

Parameters
string$text
Returns
string

Definition at line 6196 of file Parser.php.

◆ limitationWarn()

Parser::limitationWarn (   $limitationType,
  $current = '',
  $max = '' 
)

Warn the user when a parser limitation is reached Will warn at most once the user per limitation type.

The results are shown during preview and run through the Parser (See EditPage.php)

Parameters
string$limitationTypeShould be one of: 'expensive-parserfunction' (corresponding messages: 'expensive-parserfunction-warning', 'expensive-parserfunction-category') 'post-expand-template-argument' (corresponding messages: 'post-expand-template-argument-warning', 'post-expand-template-argument-category') 'post-expand-template-inclusion' (corresponding messages: 'post-expand-template-inclusion-warning', 'post-expand-template-inclusion-category') 'node-count-exceeded' (corresponding messages: 'node-count-exceeded-warning', 'node-count-exceeded-category') 'expansion-depth-exceeded' (corresponding messages: 'expansion-depth-exceeded-warning', 'expansion-depth-exceeded-category')
string | int | null$currentCurrent value
string | int | null$maxMaximum allowed, when an explicit limit has been exceeded, provide the values (optional)

Definition at line 2918 of file Parser.php.

References wfMessage().

Referenced by parse().

◆ lock()

Parser::lock ( )
protected

Lock the current instance of the parser.

This is meant to stop someone from calling the parser recursively and messing up all the strip state.

Exceptions
MWExceptionIf parser is in a parse
Returns
ScopedCallback The lock will be released once the return value goes out of scope.

Definition at line 6239 of file Parser.php.

Referenced by getPreloadText(), parse(), and preprocess().

◆ magicLinkCallback()

Parser::magicLinkCallback ( array  $m)
private
Exceptions
MWException
Parameters
array$m
Returns
string HTML

Definition at line 1741 of file Parser.php.

References getTitle(), SpecialPage\getTitleFor(), Linker\makeExternalLink(), and wfMessage().

◆ makeAnchor()

static Parser::makeAnchor (   $sectionName)
staticprivate

Definition at line 5997 of file Parser.php.

◆ makeFreeExternalLink()

Parser::makeFreeExternalLink (   $url,
  $numPostProto 
)
private

Make a free external link, given a user-supplied URL.

Parameters
string$url
int$numPostProtoThe number of characters after the protocol.
Returns
string HTML

Definition at line 1820 of file Parser.php.

References getTitle(), and Linker\makeExternalLink().

◆ makeImage()

Parser::makeImage ( Title  $title,
  $options,
  $holders = false 
)

Parse image options text and use it to make an image.

Parameters
Title$title
string$options
LinkHolderArray | bool$holders
Returns
string HTML

Definition at line 5195 of file Parser.php.

References $file, $title, $type, StringUtils\delimiterExplode(), and Linker\makeImageLink().

◆ makeKnownLinkHolder()

Parser::makeKnownLinkHolder ( Title  $nt,
  $text = '',
  $trail = '',
  $prefix = '' 
)
private

Render a forced-blue link inline; protect against double expansion of URLs if we're in a mode that prepends full URL prefixes to internal links.

Since this little disaster has to split off the trail text to avoid breaking URLs in the following text without breaking trails on the wiki links, it's been made into a horrible function.

Parameters
Title$nt
string$text
string$trail
string$prefix
Returns
string HTML-wikitext mix oh yuck

Definition at line 2708 of file Parser.php.

References Title\getPrefixedText(), and Linker\splitTrail().

◆ makeLegacyAnchor()

Parser::makeLegacyAnchor (   $sectionName)
private

Definition at line 6001 of file Parser.php.

◆ makeLimitReport()

Parser::makeLimitReport ( )
protected

Set the limit report data in the current ParserOutput, and return the limit report HTML comment.

Returns
string

Definition at line 721 of file Parser.php.

References wfHostname(), and wfMessage().

Referenced by parse().

◆ markerSkipCallback()

Parser::markerSkipCallback (   $s,
callable  $callback 
)

Call a callback function on all regions of the given text that are not inside strip markers, and replace those regions with the return value of the callback.

For example, with input:

aaa<MARKER>bbb

This will call the callback function twice, with 'aaa' and 'bbb'. Those two strings will be replaced with the value returned by the callback in each case.

Parameters
string$s
callable$callback
Returns
string

Definition at line 6166 of file Parser.php.

References $s.

◆ maybeMakeExternalImage()

Parser::maybeMakeExternalImage (   $url)
private

make an image if it's allowed, either through the global option, through the exception, or through the on-wiki whitelist

Parameters
string$url
Returns
string

Definition at line 2324 of file Parser.php.

References Linker\makeExternalImage(), and wfMessage().

◆ nextLinkID()

Parser::nextLinkID ( )
Returns
int

Definition at line 1097 of file Parser.php.

◆ normalizeLinkUrl()

static Parser::normalizeLinkUrl (   $url)
static

Replace unusual escape codes in a URL with their equivalent characters.

This generally follows the syntax defined in RFC 3986, with special consideration for HTTP query strings.

Definition at line 2243 of file Parser.php.

◆ normalizeSectionName()

static Parser::normalizeSectionName (   $text)
staticprivate

Apply the same normalization as code making links to this section would.

Parameters
string$text
Returns
string

Definition at line 6060 of file Parser.php.

◆ normalizeUrlComponent()

static Parser::normalizeUrlComponent (   $component,
  $unsafe 
)
staticprivate

Definition at line 2301 of file Parser.php.

References $matches.

◆ Options()

Parser::Options (   $x = null)

Accessor/mutator for the ParserOptions object.

Parameters
ParserOptions | null$xNew value or null to just get the current one
Returns
ParserOptions Current ParserOptions object
Deprecated:
since 1.35, use getOptions() / setOptions()

Definition at line 1089 of file Parser.php.

References wfDeprecated(), and wfSetVar().

◆ OutputType()

Parser::OutputType (   $x = null)

Accessor/mutator for the output type.

Parameters
int | null$xNew value or null to just get the current one
Returns
int
Deprecated:
since 1.35, use getOutputType()/setOutputType()

Definition at line 1054 of file Parser.php.

References wfDeprecated(), and wfSetVar().

◆ parse()

Parser::parse (   $text,
Title  $title,
ParserOptions  $options,
  $linestart = true,
  $clearState = true,
  $revid = null 
)

Convert wikitext to HTML Do not call this function recursively.

Parameters
string$textText we want to parse
-taint$textescapes_htmlnoent
Title$title
ParserOptions$options
bool$linestart
bool$clearState
int | null$revidID of the revision being rendered. This is used to render REVISION* magic words. 0 means that any current revision will be used. Null means that {{REVISIONID}}/{{REVISIONUSER}} will be empty and {{REVISIONTIMESTAMP}} will use the current timestamp.
Returns
ParserOutput A ParserOutput
-taint escaped

Definition at line 613 of file Parser.php.

References $title, ParserOptions\getDisableTitleConversion(), getTargetLanguageConverter(), internalParse(), internalParseHalfParsed(), limitationWarn(), lock(), makeLimitReport(), and startParse().

◆ parseExtensionTagAsTopLevelDoc()

Parser::parseExtensionTagAsTopLevelDoc (   $text)

Needed by Parsoid/PHP to ensure all the hooks for extensions are run in the right order.

The primary differences between this and recursiveTagParseFully are: (a) absence of $frame (b) passing true to internalParseHalfParse so all hooks are run (c) running 'ParserAfterParse' hook at the same point in the parsing pipeline when parse() does it. This kinda mimics Parsoid/JS behavior where exttags are processed by the M/w API.

This is a temporary convenience method and will go away as we proceed further with Parsoid <-> Parser.php integration.

Definition at line 899 of file Parser.php.

References internalParseHalfParsed(), and recursiveTagParse().

◆ parseLinkParameter()

Parser::parseLinkParameter (   $value)
private

Parse the value of 'link' parameter in image syntax ([[File:Foo.jpg|link=<value>]]).

Adds an entry to appropriate link tables.

Since
1.32
Parameters
string$value
Returns
array of [ type, target ], where:
  • type is one of:
    • null: Given value is not a valid link target, use default
    • ‘'no-link’: Given value is empty, do not generate a link -'link-url': Given value is a valid external link -'link-title': Given value is a valid internal link -targetis:
    • Whentypeisnullor'no-link':false
    • Whentypeis'link-url': URL string corresponding to given value
    • Whentypeis'link-title'`: Title object corresponding to given value

Definition at line 5417 of file Parser.php.

References $type.

◆ parseWidthParam()

static Parser::parseWidthParam (   $value,
  $parseHeight = true 
)
static

Parsed a width param of imagelink like 300px or 200x300px.

Parameters
string$value
bool$parseHeight
Returns
array
Since
1.20

Definition at line 6210 of file Parser.php.

◆ preprocess()

Parser::preprocess (   $text,
?Title  $title,
ParserOptions  $options,
  $revid = null,
  $frame = false 
)

Expand templates and variables in the text, producing valid, static wikitext.

Also removes comments. Do not call this function recursively.

Parameters
string$text
Title | null$title
ParserOptions$options
int | null$revid
bool | PPFrame$frame
Returns
mixed|string

Definition at line 917 of file Parser.php.

References $title, lock(), replaceVariables(), and startParse().

◆ preprocessToDom()

Parser::preprocessToDom (   $text,
  $flags = 0 
)

Preprocess some wikitext and return the document tree.

This is the ghost of replace_variables().

Parameters
string$textThe text to parse
int$flagsBitwise combination of:
  • self::PTD_FOR_INCLUSION: Handle "<noinclude>" and "<includeonly>" as if the text is being included. Default is to assume a direct page view.

The generated DOM tree must depend only on the input text and the flags. The DOM tree must be the same in OT_HTML and OT_WIKI mode, to avoid a regression of T6899.

Any flag added to the $flags parameter here, or any other parameter liable to cause a change in the DOM tree for a given text, must be passed through the section identifier in the section edit link and thus back to extractSections().

The output of this function is currently only cached in process memory, but a persistent cache may be implemented at a later date which takes further advantage of these strict dependency requirements.

Returns
PPNode

Definition at line 2842 of file Parser.php.

Referenced by getPreloadText().

◆ preSaveTransform()

Parser::preSaveTransform (   $text,
Title  $title,
User  $user,
ParserOptions  $options,
  $clearState = true 
)

Transform wiki markup when saving a page by doing "\\r\\n" -> "\\n" conversion, substituting signatures, {{subst:}} templates, etc.

Parameters
string$textThe text to transform
Title$titleThe Title object for the current article
User$userThe User object describing the current user
ParserOptions$optionsParsing options
bool$clearStateWhether to clear the parser state first
Returns
string The altered wiki markup

Definition at line 4477 of file Parser.php.

References $title, and ParserOptions\getPreSaveTransform().

◆ pstPass2()

Parser::pstPass2 (   $text,
User  $user 
)
private

Pre-save transform helper function.

Parameters
string$text
User$user
Returns
string

Definition at line 4517 of file Parser.php.

References $t, and getTitle().

◆ recursivePreprocess()

Parser::recursivePreprocess (   $text,
  $frame = false 
)

Recursive parser entry point that can be called from an extension tag hook.

Parameters
string$textText to be expanded
bool | PPFrame$frameThe frame to use for expanding any template variables
Returns
string
Since
1.19

Definition at line 942 of file Parser.php.

References replaceVariables().

◆ recursiveTagParse()

Parser::recursiveTagParse (   $text,
  $frame = false 
)

Half-parse wikitext to half-parsed HTML.

This recursive parser entry point can be called from an extension tag hook.

The output of this function IS NOT SAFE PARSED HTML; it is "half-parsed" instead, which means that lists and links have not been fully parsed yet, and strip markers are still present.

Use recursiveTagParseFully() to fully parse wikitext to output-safe HTML.

Use this function if you're a parser tag hook and you want to parse wikitext before or after applying additional transformations, and you intend to return the result as hook output, which will cause it to go through the rest of parsing process automatically.

If $frame is not provided, then template variables (e.g., {{{1}}}) within $text are not expanded

Parameters
string$textText extension wants to have parsed
-taint$textescapes_htmlnoent
bool | PPFrame$frameThe frame to use for expanding any template variables
Returns
string UNSAFE half-parsed HTML
-taint escaped

Definition at line 848 of file Parser.php.

References internalParse().

Referenced by parseExtensionTagAsTopLevelDoc(), and recursiveTagParseFully().

◆ recursiveTagParseFully()

Parser::recursiveTagParseFully (   $text,
  $frame = false 
)

Fully parse wikitext to fully parsed HTML.

This recursive parser entry point can be called from an extension tag hook.

The output of this function is fully-parsed HTML that is safe for output. If you're a parser tag hook, you might want to use recursiveTagParse() instead.

If $frame is not provided, then template variables (e.g., {{{1}}}) within $text are not expanded

Since
1.25
Parameters
string$textText extension wants to have parsed
-taint$textescapes_htmlnoent
bool | PPFrame$frameThe frame to use for expanding any template variables
Returns
string Fully parsed HTML
-taint escaped

Definition at line 874 of file Parser.php.

References internalParseHalfParsed(), and recursiveTagParse().

Referenced by CoreTagHooks\indicator().

◆ renderImageGallery()

Parser::renderImageGallery (   $text,
array  $params 
)

Renders an image gallery from a text with one line per image.

text labels may be given by using |-style alternative text. E.g. Image:one.jpg|The number "1" Image:tree.jpg|A tree given as text will return the HTML of a gallery with two images, labeled 'The number "1"' and 'A tree'.

Parameters
string$text
array$params
Returns
string HTML

Definition at line 4979 of file Parser.php.

References $file, $line, $lines, $matches, $title, $type, StringUtils\delimiterExplode(), StringUtils\explode(), getTitle(), and NS_FILE.

◆ replaceLinkHolders()

Parser::replaceLinkHolders ( $text,
  $options = 0 
)

Replace "<!--LINK-->" link placeholders with actual links, in the buffer Placeholders created in Linker::link()

Parameters
string&$text
int$options
Deprecated:
since 1.34; should not be used outside parser class.

Definition at line 4939 of file Parser.php.

◆ replaceLinkHoldersPrivate()

Parser::replaceLinkHoldersPrivate ( $text,
  $options = 0 
)
private

Replace "<!--LINK-->" link placeholders with actual links, in the buffer Placeholders created in Linker::link()

Parameters
string&$text
int$options

Definition at line 4950 of file Parser.php.

◆ replaceLinkHoldersText()

Parser::replaceLinkHoldersText (   $text)
private

Replace "<!--LINK-->" link placeholders with plain text of links (not HTML-formatted).

Parameters
string$text
Returns
string

Definition at line 4961 of file Parser.php.

◆ replaceSection()

Parser::replaceSection (   $oldText,
  $sectionId,
  $newText 
)

This function returns $oldtext after the content of the section specified by $section has been replaced with $text.

If the target section does not exist, $oldtext is returned unchanged.

Parameters
string$oldTextFormer text of the article
string | int$sectionIdSection identifier as a number or string (e.g. 0, 1 or 'T-1').
string$newTextReplacing text
Returns
string Modified text

Definition at line 5717 of file Parser.php.

◆ replaceVariables()

Parser::replaceVariables (   $text,
  $frame = false,
  $argsOnly = false 
)

Replace magic variables, templates, and template arguments with the appropriate text.

Templates are substituted recursively, taking care to avoid infinite loops.

Note that the substitution depends on value of $mOutputType: self::OT_WIKI: only {{subst:}} templates self::OT_PREPROCESS: templates but not extension tags self::OT_HTML: all templates and extension tags

Parameters
string$textThe text to transform
false | PPFrame | array$frameObject describing the arguments passed to the template. Arguments may also be provided as an associative array, as was the usual case before MW1.12. Providing arguments this way may be useful for extensions wishing to perform variable replacement explicitly.
bool$argsOnlyOnly do argument (triple-brace) expansion, not double-brace expansion.
Returns
string

Definition at line 2867 of file Parser.php.

Referenced by preprocess(), and recursivePreprocess().

◆ resetOutput()

Parser::resetOutput ( )

Reset the ParserOutput.

Definition at line 591 of file Parser.php.

Referenced by clearState().

◆ setDefaultSort()

Parser::setDefaultSort (   $sort)

Mutator for $mDefaultSort.

Parameters
string$sortNew value

Definition at line 5957 of file Parser.php.

◆ setFunctionHook()

Parser::setFunctionHook (   $id,
callable  $callback,
  $flags = 0 
)

Create a function, e.g.

{{sum:1|2|3}} The callback function should have the form: function myParserFunction( &$parser, $arg1, $arg2, $arg3 ) { ... }

Or with Parser::SFH_OBJECT_ARGS: function myParserFunction( $parser, $frame, $args ) { ... }

The callback may either return the text result of the function, or an array with the text in element 0, and a number of flags in the other elements. The names of the flags are specified in the keys. Valid flags are: found The text returned is valid, stop processing the template. This is on by default. nowiki Wiki markup in the return value should be escaped isHTML The returned text is HTML, armour it against wikitext transformation

Parameters
string$idThe magic word ID
callable$callbackThe callback function (and object) to use
int$flagsA combination of the following flags: Parser::SFH_NO_HASH No leading hash, i.e. {{plural:...}} instead of {{if:...}}

Parser::SFH_OBJECT_ARGS Pass the template arguments as PPNode objects instead of text. This allows for conditional expansion of the parse tree, allowing you to eliminate dead branches and thus speed up parsing. It is also possible to analyse the parse tree of the arguments, and to control the way they are expanded.

The $frame parameter is a PPFrame. This can be used to produce expanded text from the arguments, for instance: $text = isset( $args[0] ) ? $frame->expand( $args[0] ) : '';

For technical reasons, $args[0] is pre-expanded and will be a string. This may change in future versions. Please call $frame->expand() on it anyway so that your code keeps working if/when this is changed.

If you want whitespace to be trimmed from $args, you need to do it yourself, post- expansion.

Please read the documentation in includes/parser/Preprocessor.php for more information about the methods available in PPFrame and PPNode.

Exceptions
MWException
Returns
string|callable The old callback function for this name, if any

Definition at line 4863 of file Parser.php.

◆ setFunctionTagHook()

Parser::setFunctionTagHook (   $tag,
callable  $callback,
  $flags 
)

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.

Parameters
string$tag
callable$callback
int$flags
Exceptions
MWException
Returns
null
Deprecated:
since 1.35

Definition at line 4915 of file Parser.php.

References wfDeprecated().

◆ setHook()

Parser::setHook (   $tag,
callable  $callback 
)

Create an HTML-style tag, e.g.

"<yourtag>special text</yourtag>" The callback should have the following form: function myParserHook( $text, $params, $parser, $frame ) { ... }

Transform and return $text. Use $parser for any required context, e.g. use $parser->getTitle() and $parser->getOptions() not $wgTitle or $wgOut->mParserOptions

Hooks may return extended information by returning an array, of which the first numbered element (index 0) must be the return string, and all other entries are extracted into local variables within an internal function in the Parser class.

This interface (introduced r61913) appears to be undocumented, but 'markerType' is used by some core tag hooks to override which strip array their results are placed in. Use great caution if attempting this interface, as it is not documented and injudicious use could smash private variables.

Parameters
string$tagThe tag to use, e.g. 'hook' for "<hook>"
callable$callbackThe callback function (and object) to use for the tag
Exceptions
MWException
Returns
callable|null The old value of the mTagHooks array associated with the hook

Definition at line 4797 of file Parser.php.

◆ setLinkID()

Parser::setLinkID (   $id)
Parameters
int$id

Definition at line 1104 of file Parser.php.

◆ setOptions()

Parser::setOptions ( ParserOptions  $options)

Mutator for the ParserOptions object.

Parameters
ParserOptions$optionsThe new parser options
Since
1.35

Definition at line 1078 of file Parser.php.

◆ setOutputFlag()

Parser::setOutputFlag ( string  $flag,
string  $reason 
)
private

Sets the flag on the parser output but also does some debug logging.

Note that there is a copy of this method in CoreMagicVariables as well.

Parameters
string$flag
string$reason

Definition at line 6313 of file Parser.php.

◆ setOutputType()

Parser::setOutputType (   $ot)

Mutator for the output type.

Parameters
int$otOne of the Parser::OT_… constants

Definition at line 1036 of file Parser.php.

◆ setTitle()

Parser::setTitle ( Title  $t = null)

Set the context title.

Parameters
Title | null$t

Definition at line 991 of file Parser.php.

References $t, and NS_SPECIAL.

◆ setUser()

Parser::setUser ( ?User  $user)

Set the current user.

Should only be used when doing pre-save transform.

Parameters
User | null$userUser object or null (to reset)

Definition at line 982 of file Parser.php.

◆ startExternalParse()

Parser::startExternalParse ( ?Title  $title,
ParserOptions  $options,
  $outputType,
  $clearState = true,
  $revId = null 
)

Set up some variables which are usually set up in parse() so that an external function can call some class members with confidence.

Parameters
Title | null$title
ParserOptions$options
int$outputType
bool$clearState
int | null$revId

Definition at line 4719 of file Parser.php.

References $title.

◆ startParse()

Parser::startParse ( ?Title  $title,
ParserOptions  $options,
  $outputType,
  $clearState = true 
)
private
Parameters
Title | null$title
ParserOptions$options
int$outputType
bool$clearState

Definition at line 4734 of file Parser.php.

References $title.

Referenced by getPreloadText(), parse(), and preprocess().

◆ statelessFetchRevision()

static Parser::statelessFetchRevision ( Title  $title,
  $parser = false 
)
static

Wrapper around Revision::newFromTitle to allow passing additional parameters without passing them on to it.

Deprecated:
since 1.35, use statelessFetchRevisionRecord
Since
1.24
Parameters
Title$title
Parser | bool$parser
Returns
Revision|bool False if missing

Definition at line 3498 of file Parser.php.

References $title, and wfDeprecated().

◆ statelessFetchRevisionRecord()

static Parser::statelessFetchRevisionRecord ( Title  $title,
  $parser = null 
)
static

Wrapper around Revision::newFromTitle to allow passing additional parameters without passing them on to it.

Since
1.34
Parameters
Title$title
Parser | null$parser
Returns
RevisionRecord|bool False if missing

Definition at line 3515 of file Parser.php.

References $title.

◆ statelessFetchTemplate()

static Parser::statelessFetchTemplate (   $title,
  $parser = false 
)
static

Static function to get a template Can be overridden via ParserOptions::setTemplateCallback().

Parameters
Title$title
bool | Parser$parser
Returns
array|DeprecatablePropertyArray

Definition at line 3586 of file Parser.php.

References $content, $title, NS_MEDIAWIKI, and wfMessage().

◆ stripAltText()

Parser::stripAltText (   $caption,
  $holders 
)
private
Parameters
string$caption
LinkHolderArray | bool$holders
Returns
mixed|string

Definition at line 5447 of file Parser.php.

◆ stripOuterParagraph()

static Parser::stripOuterParagraph (   $html)
static

Strip outer.

tag from the HTML source of a single paragraph.

Returns original HTML if the

tag has any attributes, if there's no wrapping

tag, or if there is more than one

tag in the input HTML.

Parameters
string$html
Returns
string
Since
1.24

Definition at line 6267 of file Parser.php.

◆ stripSectionName()

Parser::stripSectionName (   $text)

Strips a text string of wikitext for use in a section anchor.

Accepts a text string and then removes all wikitext from the string and leaves only the resultant text (i.e. the result of [[User:WikiSysop|Sysop]] would be "Sysop" and the result of [[User:WikiSysop]] would be "User:WikiSysop") - this is intended to create valid section anchors by mimicing the output of the parser when headings are parsed.

Parameters
string$textText string to be stripped of wikitext for use in a Section anchor
Returns
string Filtered text string

Definition at line 6088 of file Parser.php.

References StringUtils\delimiterReplace().

◆ Title()

Parser::Title ( Title  $x = null)

Accessor/mutator for the Title object.

Parameters
Title | null$xTitle object or null to just get the current one
Returns
Title|null
Deprecated:
since 1.35, use getTitle() / setTitle()

Definition at line 1018 of file Parser.php.

◆ transformMsg()

Parser::transformMsg (   $text,
ParserOptions  $options,
Title  $title = null 
)

Wrapper for preprocess()

Parameters
string$textThe text to preprocess
ParserOptions$options
Title | null$titleTitle object or null to use $wgTitle
Returns
string

Definition at line 4753 of file Parser.php.

References $title, and $wgTitle.

◆ validateSig()

Parser::validateSig (   $text)

Check that the user's signature contains no bad XML.

Parameters
string$text
Returns
string|bool An expanded string, or false if invalid.

Definition at line 4653 of file Parser.php.

Member Data Documentation

◆ $badFileLookup

BadFileLookup Parser::$badFileLookup
private

Definition at line 355 of file Parser.php.

◆ $contLang

Language Parser::$contLang
private

Definition at line 325 of file Parser.php.

◆ $currentRevisionCache

MapCacheLRU null Parser::$currentRevisionCache
private
Since
1.24

A cache of the current revisions of titles. Keys are $title->getPrefixedDbKey()

Definition at line 303 of file Parser.php.

◆ $factory

ParserFactory Parser::$factory
private

Definition at line 331 of file Parser.php.

◆ $hookContainer

HookContainer Parser::$hookContainer
private

Definition at line 358 of file Parser.php.

◆ $hookRunner

HookRunner Parser::$hookRunner
private

Definition at line 361 of file Parser.php.

◆ $languageConverterFactory

LanguageConverterFactory Parser::$languageConverterFactory
private

Definition at line 328 of file Parser.php.

◆ $linkRendererFactory

LinkRendererFactory Parser::$linkRendererFactory
private

Definition at line 346 of file Parser.php.

◆ $logger

LoggerInterface Parser::$logger
private

Definition at line 352 of file Parser.php.

◆ $magicWordFactory

MagicWordFactory Parser::$magicWordFactory
private

Definition at line 322 of file Parser.php.

◆ $mAutonumber

Parser::$mAutonumber
private

Definition at line 205 of file Parser.php.

◆ $mConf

array Parser::$mConf
private
Deprecated:
since 1.34, there should be no need to use this

Definition at line 187 of file Parser.php.

◆ $mDefaultSort

Parser::$mDefaultSort
private

Definition at line 234 of file Parser.php.

◆ $mDoubleUnderscores

Parser::$mDoubleUnderscores
Deprecated:
since 1.35

Definition at line 239 of file Parser.php.

◆ $mExpensiveFunctionCount

Parser::$mExpensiveFunctionCount
Deprecated:
since 1.35

Definition at line 241 of file Parser.php.

◆ $mExtLinkBracketedRegex

Parser::$mExtLinkBracketedRegex
private

Definition at line 190 of file Parser.php.

◆ $mFirstCall

bool Parser::$mFirstCall = true

Whether firstCallInit still needs to be called.

Deprecated:
since 1.35

Definition at line 169 of file Parser.php.

◆ $mForceTocPosition

Parser::$mForceTocPosition
private

Definition at line 244 of file Parser.php.

◆ $mFunctionHooks

Parser::$mFunctionHooks = []
Deprecated:
since 1.35; use Parser::getFunctionHooks()

Definition at line 156 of file Parser.php.

◆ $mFunctionSynonyms

Parser::$mFunctionSynonyms = [ 0 => [], 1 => [] ]
private

Definition at line 157 of file Parser.php.

◆ $mFunctionTagHooks

Parser::$mFunctionTagHooks = []
private

Definition at line 158 of file Parser.php.

◆ $mGeneratedPPNodeCount

Parser::$mGeneratedPPNodeCount
Deprecated:
since 1.35, Preprocessor_DOM was removed and this counter is no longer incremented by anything.

Definition at line 231 of file Parser.php.

◆ $mHeadings

Parser::$mHeadings

Definition at line 237 of file Parser.php.

◆ $mHighestExpansionDepth

Parser::$mHighestExpansionDepth
Deprecated:
since 1.35

Definition at line 233 of file Parser.php.

◆ $mImageParams

Parser::$mImageParams = []
private

Definition at line 161 of file Parser.php.

◆ $mImageParamsMagicArray

Parser::$mImageParamsMagicArray = []
private

Definition at line 162 of file Parser.php.

◆ $mIncludeSizes

Parser::$mIncludeSizes
Deprecated:
since 1.35

Definition at line 224 of file Parser.php.

◆ $mInParse

bool string Parser::$mInParse = false

Recursive call protection.

Definition at line 311 of file Parser.php.

◆ $mInputSize

Parser::$mInputSize = false
Deprecated:
since 1.35

Definition at line 285 of file Parser.php.

◆ $mLangLinkLanguages

array Parser::$mLangLinkLanguages
private

Array with the language name of each language link (i.e.

the interwiki prefix) in the key, value arbitrary. Used to avoid sending duplicate language links to the ParserOutput.

Definition at line 295 of file Parser.php.

◆ $mLinkHolders

LinkHolderArray Parser::$mLinkHolders
private

Definition at line 216 of file Parser.php.

◆ $mLinkID

int Parser::$mLinkID
Deprecated:
since 1.35; use Parser::nextLinkID() / ::setLinkID()

Definition at line 222 of file Parser.php.

◆ $mLinkRenderer

LinkRenderer Parser::$mLinkRenderer
private

Definition at line 319 of file Parser.php.

◆ $mMarkerIndex

Parser::$mMarkerIndex = 0
Deprecated:
since 1.35

Definition at line 164 of file Parser.php.

◆ $mOptions

ParserOptions null Parser::$mOptions
Deprecated:
since 1.35, use Parser::getOptions()

Definition at line 261 of file Parser.php.

◆ $mOutput

ParserOutput Parser::$mOutput
Deprecated:
since 1.35; use Parser::getOutput()

Definition at line 204 of file Parser.php.

◆ $mOutputType

Parser::$mOutputType
private

Definition at line 271 of file Parser.php.

◆ $mPPNodeCount

Parser::$mPPNodeCount
Deprecated:
since 1.35

Definition at line 226 of file Parser.php.

◆ $mPreprocessor

Preprocessor Parser::$mPreprocessor
Deprecated:
since 1.35

Definition at line 197 of file Parser.php.

◆ $mProfiler

SectionProfiler Parser::$mProfiler
private

Definition at line 314 of file Parser.php.

◆ $mRevisionId

Parser::$mRevisionId
Deprecated:
since 1.35, use Parser::getRevisionId()

Definition at line 277 of file Parser.php.

◆ $mRevisionObject

Parser::$mRevisionObject
Deprecated:
since 1.35, use Parser::getRevisionObject()

Definition at line 275 of file Parser.php.

◆ $mRevisionRecordObject

RevisionRecord null Parser::$mRevisionRecordObject
private

Definition at line 288 of file Parser.php.

◆ $mRevisionSize

Parser::$mRevisionSize
Deprecated:
since 1.35, use Parser::getRevisionSize()

Definition at line 283 of file Parser.php.

◆ $mRevisionTimestamp

Parser::$mRevisionTimestamp
Deprecated:
since 1.35, use Parser::getRevisionTimestamp()

Definition at line 279 of file Parser.php.

◆ $mRevisionUser

Parser::$mRevisionUser
Deprecated:
since 1.35, use Parser::getRevisionUser()

Definition at line 281 of file Parser.php.

◆ $mShowToc

Parser::$mShowToc
Deprecated:
since 1.35

Definition at line 243 of file Parser.php.

◆ $mStripList

Parser::$mStripList = []
private

Definition at line 159 of file Parser.php.

◆ $mStripState

StripState Parser::$mStripState
Deprecated:
since 1.35, use Parser::getStripState()

Definition at line 211 of file Parser.php.

◆ $mSubstWords

MagicWordArray Parser::$mSubstWords
private

Definition at line 181 of file Parser.php.

◆ $mTagHooks

Parser::$mTagHooks = []
Deprecated:
since 1.35; use Parser::getTags()

Definition at line 154 of file Parser.php.

◆ $mTitle

Title null Parser::$mTitle

Since 1.34, leaving mTitle uninitialized or setting mTitle to null is deprecated.

Deprecated:
since 1.35, use Parser::getTitle()

Definition at line 270 of file Parser.php.

◆ $mTplDomCache

array Parser::$mTplDomCache
private

Definition at line 246 of file Parser.php.

◆ $mTplRedirCache

Parser::$mTplRedirCache
private

Definition at line 235 of file Parser.php.

◆ $mUrlProtocols

Parser::$mUrlProtocols
private

Definition at line 190 of file Parser.php.

◆ $mUser

User Parser::$mUser
Deprecated:
since 1.35, use Parser::getUser()

Definition at line 252 of file Parser.php.

◆ $mVarCache

Parser::$mVarCache = []
private

Definition at line 160 of file Parser.php.

◆ $mVariables

MagicWordArray Parser::$mVariables
private

Definition at line 176 of file Parser.php.

◆ $nsInfo

NamespaceInfo Parser::$nsInfo
private

Definition at line 349 of file Parser.php.

◆ $ot

Parser::$ot
Deprecated:
since 1.35

Definition at line 273 of file Parser.php.

◆ $specialPageFactory

SpecialPageFactory Parser::$specialPageFactory
private

Definition at line 334 of file Parser.php.

◆ $svcOptions

ServiceOptions Parser::$svcOptions
private

This is called $svcOptions instead of $options like elsewhere to avoid confusion with $mOptions, which is public and widely used, and also with the local variable $options used for ParserOptions throughout this file.

Definition at line 343 of file Parser.php.

◆ EXT_IMAGE_REGEX

const Parser::EXT_IMAGE_REGEX
private
Initial value:
= '/^(http:\/\/|https:\/\/)((?:\\[(?i:[0-9a-f:.]+)\\])?[^][<>"\\x00-\\x20\\x7F\p{Zs}\x{FFFD}]+)
\\/([A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]+)\\.((?i)gif|png|jpg|jpeg)$/Sxu'

Definition at line 110 of file Parser.php.

◆ EXT_LINK_ADDR

const Parser::EXT_LINK_ADDR = '(?:[0-9.]+|\\[(?i:[0-9a-f:.]+)\\]|[^][<>"\\x00-\\x20\\x7F\p{Zs}\x{FFFD}])'
private

Definition at line 107 of file Parser.php.

◆ EXT_LINK_URL_CLASS

const Parser::EXT_LINK_URL_CLASS = '[^][<>"\\x00-\\x20\\x7F\p{Zs}\x{FFFD}]'

Definition at line 103 of file Parser.php.

◆ MARKER_PREFIX

const Parser::MARKER_PREFIX = "\x7f'\"`UNIQ-"

Definition at line 146 of file Parser.php.

◆ OT_HTML

const Parser::OT_HTML = 1

Definition at line 121 of file Parser.php.

◆ OT_MSG

const Parser::OT_MSG = 3

Definition at line 124 of file Parser.php.

◆ OT_PLAIN

const Parser::OT_PLAIN = 4

Definition at line 126 of file Parser.php.

◆ OT_PREPROCESS

const Parser::OT_PREPROCESS = 3

Definition at line 123 of file Parser.php.

◆ OT_WIKI

const Parser::OT_WIKI = 2

Definition at line 122 of file Parser.php.

◆ PTD_FOR_INCLUSION

const Parser::PTD_FOR_INCLUSION = 1

Definition at line 117 of file Parser.php.

◆ SFH_NO_HASH

const Parser::SFH_NO_HASH = 1

Definition at line 94 of file Parser.php.

◆ SFH_OBJECT_ARGS

const Parser::SFH_OBJECT_ARGS = 2

Definition at line 95 of file Parser.php.

◆ SPACE_NOT_NL

const Parser::SPACE_NOT_NL = '(?:\t|&nbsp;|&\#0*160;|&\#[Xx]0*[Aa]0;|\p{Zs})'
private

Definition at line 114 of file Parser.php.

◆ TOC_END

const Parser::TOC_END = '</mw:toc>'

Definition at line 150 of file Parser.php.

◆ TOC_START

const Parser::TOC_START = '<mw:toc>'

Definition at line 149 of file Parser.php.

◆ VERSION

const Parser::VERSION = '1.6.4'

Update this version number when the ParserOutput format changes in an incompatible way, so the parser cache can automatically discard old data.

Definition at line 91 of file Parser.php.


The documentation for this class was generated from the following file: