Manual:Hooks/InternalParseBeforeLinks

Details
$text will hold the text for the page. To change the page text, modify this value, just as explained in ParserBeforeStrip. Note that you should not access certain global variables during this hook, as is documented in Parser.php.

This hook is intended to enable extensions that provide additional syntax features. It is usually desirable that those features interact with templates, comments, and other special functions of wiki code. For instance, assume that some extension implements automatic linking of certain key-words, say names of known users. So whenever someone types "Markus Krötzsch" the extension transforms this into " Markus Krötzsch ". Now consider the folloing example text:

Markus Krötzsch &lt;nowiki>Markus Krötzsch&lt;/nowiki> Markus &lt;!-- some comment --> Krötzsch Krötzsch

Where we assume that the template "Inserttext" just pastes the first parameter. In this case, users might expect the extension to transform line 1, 3, and 4, but not line 2. However, other parser hooks (e.g. ParserBeforeStrip and ParserAfterStrip) run before the wiki code is processed, such that lines 1 and 2 would be transformed instead. This parser hook fixes this issue to some extent.

The downside is that some processing steps have been done before, and will no longer be performed on the output of the hook. So the hook should insert only simple wiki code with links, and safe HTML code that is allowed for any user.

Also note that this hook is called any time some parsing happens, not just for displaying article contents. For instance, edit disclaimer or image galleries also are piped thorugh a parser. Thus, the hook must be very careful when adding contents to the text. For further discussion, see ParserBeforeStrip.