Manual:Hooks/ParserAfterTidy

From MediaWiki.org
Jump to: navigation, search
ParserAfterTidy
Available from version 1.5.0
Used to add some final processing to the fully-rendered page output
Define function:
public static function onParserAfterTidy( &$parser, &$text ) { ... }
Attach hook:
$wgHooks['ParserAfterTidy'][] = 'MyExtensionHooks::onParserAfterTidy';
Called from: File(s): Parser.php

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

Details[edit]

  • $parser: Parser object. Can be used to manually parse a portion of wiki text from the $text.
  • $text: Represents the text for page.

This hook is commonly used to re-introduce content that was earlier embedded by an extension during page rendering, either encoded or represented by a marker, by searching for it and replacing it with HTML content. Such a techniques allows MediaWiki extensions to output HTML that isn't mangled by the parser, e.g., blacklisted HTML tags. See Tag extension example

See also[edit]