Manual:Hooks/ParserAfterTidy: Difference between revisions
Appearance
→See also: Also ParserBeforeTidy |
m 1 revision imported: Initial |
||
(No difference)
|
Latest revision as of 17:03, 29 December 2024
ParserAfterTidy | |
---|---|
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate> Used to add some final processing to the fully-rendered page output | |
<translate> Define function:</translate> | public static function onParserAfterTidy( Parser $parser, &$text ) { ... }
|
<translate> Attach hook:</translate> | <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
"Hooks": {
"ParserAfterTidy": "MediaWiki\\Extension\\MyExtension\\Hooks::onParserAfterTidy"
}
}
|
<translate> Called from:</translate> | <translate> File(s):</translate> parser/Parser.php |
<translate> Interface:</translate> | ParserAfterTidyHook.php |
<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:ParserAfterTidy extensions</tvar>.</translate>
Details
$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