Hello,
I have what I think is strange behaviour with parser called by the API
and tag extensions.
Here is the code of a tag extension :
function efParserInit() {
global $wgParser;
$wgParser->setHook( 'foo', 'effooRender' );
$wgParser->setHook( 'bar', 'efbarRender' );
return true;
}
function effooRender( $input, $args, &$parser )
{
$output = $parser->recursiveTagParse( $input );
return "<div class=\"foo\">" . $output . "</div>";
}
function efbarRender( $input, $args, &$parser )
{
$output = $parser->recursiveTagParse( $input );
return "<div class=\"bar\">" . $output . "</div>";
}
I crate a page on my Wiki with the following text :
<foo>test1<bar>'''test2'''</bar></foo>
When I view the HTML code in my browser, I get :
<div class="foo">test1<div class="bar"><b>test2</b></div></div>
But when I try : wget
"http://mywiki/wiki/api.php?action=query&titles=mypage&prop=revisions&rvprop=content&rvexpandtemplates&rvgeneratexml&format=xml",
I get the following in the "parsetree" attribute of the "rev" element ":
<ext><name>foo</name><attr/><inner>test1&lt;bar&gt;'''test2'''&lt;/bar&gt;</inner><close>&lt;/foo&gt;</close></ext>
(sorry for this ugly line...).
My problem is here : there is only one "ext" element which correspond to my
"foo" tag. I was waiting two "ext" elements : one for "foo" tag and one for
"bar" tag.
This is just I want.
Is this behaviour normal ?
A little bit of debug show that the includes/parser/Parser.php, the
"extensionSubstitution" function is only called one time when I access my
page via the API and three times when I access it via the browser. Is the
text parsed not the same in the two cases ? Is it something wrong in my API
call ?
Regards,
Alex
_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l