I found another solution that seems to work. Don't know why or how but
it fixes my problem.
global $wgTitle, $wgParser, $wgOut;
$output = //do some stuff
$output = $wgParser->parse( $output, $wgTitle, $wgOut->mParserOptions,
true );
return $output->getText();
Note: This e-mail contains privileged and confidential information and is for the sole use
of the intended recipient(s). If you are not an intended recipient, you are hereby kindly
requested to refrain from printing, copying, or distributing the information contained
herein. Furthermore, any other use of the information contained herein is strictly
prohibited. If you have received this transmission in error, please kindly notify the
sender immediately and destroy all copies of the original message.