Manual:Hooks/ParserBeforeInternalParse

From mediawiki.org
ParserBeforeInternalParse
Available from version 1.6.0
Replaces the normal processing of stripped wiki text with custom processing. Used primarily to support alternatives (rather than additions) to the core MediaWiki markup syntax.
Define function:
public static function onParserBeforeInternalParse( Parser &$parser, &$text, &$strip_state ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"ParserBeforeInternalParse": "MediaWiki\\Extension\\MyExtension\\Hooks::onParserBeforeInternalParse"
	}
}
Called from: File(s): parser/Parser.php
Interface: ParserBeforeInternalParseHook.php

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:ParserBeforeInternalParse extensions.


Details[edit]

  • $parser: ...(Add description)...
  • $text: ...(Add description)...
  • $strip_state: ...(Add description)...


Usage[edit]

This hook is called at the start of the post-strip wiki text parsing process. It returns true if normal wiki text processing should proceed and false if the hook is designed to take over or replace the normal processing of wiki text. The hook implementation generally has two phases:

  1. Check to see if the article and system state indicate a take over of normal wiki text processing. This may be determined by a combination of configuration properties and/or specific strings found within the article text. If not found, return true so as to allow normal processing to continue.
  2. If conditions permit the takeover of wiki text processing, do the specialized parsing and place the result in $text. Return false to indicate that normal wiki-text processing should be skipped and that the string is ready for unstripping (restoration of the wiki text protected by ‎<nowiki> tags), and the whole before-tidy-after sequence.