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 ":
&lt;ext&gt;&lt;name&gt;foo&lt;/name&gt;&lt;attr/&gt;&lt;inner&gt;test1&amp;lt;bar&amp;gt;&#039;&#039;&#039;test2&#039;&#039;&#039;&amp;lt;/bar&amp;gt;&lt;/inner&gt;&lt;close&gt;&amp;lt;/foo&amp;gt;&lt;/close&gt;&lt;/ext&gt;

(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
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to