Manual:Hooks/ParserBeforeInternalParse

From MediaWiki.org
Jump to: navigation, search
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, &$text, &$strip_state ) { ... }
Attach hook:
$wgHooks['ParserBeforeInternalParse'][] = 'MyExtensionHooks::onParserBeforeInternalParse';
Called from: File(s): Parser.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.

Note: If you merely wish to filter or add to wiki text before the normal processing, consider using ParserAfterStrip extension instead of this hook. This is a much less invasive method that lets one insert processing after the stripping process(before-strip-after) is complete but before normal wiki-text processing has begun.