Manual:Hooks/ParserAfterTidy

From mediawiki.org
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 $parser, &$text ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"ParserAfterTidy": "MediaWiki\\Extension\\MyExtension\\Hooks::onParserAfterTidy"
	}
}
Called from: File(s): parser/Parser.php
Interface: ParserAfterTidyHook.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 technique 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]