Manual:Hooks/ApiFormatHighlight

ApiFormatHighlight
Available from version 1.25.0 (Gerrit change 161093)
Use to syntax-highlight API pretty-printed output. When highlighting, add output to $context->getOutput() and return false.
Define function:
public static function onApiFormatHighlight( $context, $text, $mime, $format ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"ApiFormatHighlight": "MediaWiki\\Extension\\MyExtension\\Hooks::onApiFormatHighlight"
	}
}
Called from: File(s): api/ApiFormatBase.php
Function(s): closePrinter
Interface: ApiFormatHighlightHook.php

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


Details

edit
  • $context: An IContextSource.
  • $text: Text to be highlighted.
  • $mime: MIME type of $text.
  • $format: API format code for $text.