My setup:
Mediawiki: 1.23.5 PHP: 5.5.21 MYSQL:5.6.23
I'm seeing a weird bug with some custom tags that rely on parsing wikitext. The following example is a simplification (I'm just parsing a div tag) to highlight that the problem is related to the use of the parser:
class myClass{
public static function ExtensionSetupParserFunction( Parser$parser ) {
$parser->setHook( 'mywiki-tag', 'self::ExtensionRenderParserFunction');
return true;
}
public static function ExtensionRenderParserFunction($input, array $args, Parser $parser, PPFrame $frame ) {
#simple div tag
$wikiText='<div>'.$input.'</div>';
#let's parse it
$newParser=new Parser();
$res=$newParser->parse($wikiText,$parser->getTitle(),$parser->getOptions())->getText();
#return
return $res;
}
#end of class
}
#Now register the tag:
$wgHooks['ParserFirstCallInit'][] = 'myClass::ExtensionSetupParserFunction';
Now let's use this tag:
<mywiki-tag>input</mywiki-tag>a <mywiki-tag>input</mywiki-tag> a
The html corresponding to the first line:
<div>input</div> a
The second line has an extra pre tag around 'a':
<div>input</div><pre> a</pre> .
In the rendering function, if we remove the div tags and just parse the input directly then everything is OK. Any idea what's going on here?