Hi,
I have an extension that needs to parse some wiki text. I started with:
$title = $parser->internalParse($title);
but found that links were not always processing correctly [[Main Page]] was saying as that, but interestingly the first [[:image: ]] tags was parsing
$title = $parser->parse($title,$wgTitle,ParserOptions::newFromUser($wgUser),false,false)->getText();
... however did. This is with MW 1.13.1.
However now the batch processes take forever, and the culprit is the "->parse" - it seems to take exponentially longer to run. internalParse runs quicker, so for the time being I have detected commandline functions and NS_SPECIAL pages and sent it that way (as I don't really care if the pages parse correctly or not there).
Are there any expected known limitations of internalParse? Should it always output the same as parse or are there certain cases which will never work with it?
Kind regards,
Alex
Alex Powell schreef:
Hi,
I have an extension that needs to parse some wiki text. I started with:
$title = $parser->internalParse($title);
but found that links were not always processing correctly [[Main Page]] was saying as that, but interestingly the first [[:image: ]] tags was parsing
You mean [[Main Page]] didn't turn into a link while [[:Image:Foo.jpg]] did? Are you sure [[Main Page]] isn't a self-link?
$title =
$parser->parse($title,$wgTitle,ParserOptions::newFromUser($wgUser),false,false)->getText();
... however did. This is with MW 1.13.1.
However now the batch processes take forever, and the culprit is the "->parse" - it seems to take exponentially longer to run. internalParse runs quicker, so for the time being I have detected commandline functions and NS_SPECIAL pages and sent it that way (as I don't really care if the pages parse correctly or not there).
Are there any expected known limitations of internalParse? Should it always output the same as parse or are there certain cases which will never work with it?
Are you doing this inside a hook that's called by the parser? If so, you should not call $parser->parse() but use $parser->recursiveTagParse() instead (I don't know whether $parser->internalParse() is forbidden as well).
Roan Kattouw (Catrope)
Hi Roan,
Thankyou. recursiveTagParse seems to work better - and avoids my ugly hack.
They're all set up with setFunctionHook as parser functions, and no I was not on Main Page with the test. I am in a slightly complicated position as I am also in a parser hook wrapping them up - a legacy design that gained traction I don't want to remove if I don't have to - possibly that is interferring with internalparse...
Kind regards,
Alex
2009/1/13 Roan Kattouw roan.kattouw@home.nl
Alex Powell schreef:
Hi,
I have an extension that needs to parse some wiki text. I started with:
$title = $parser->internalParse($title);
but found that links were not always processing correctly [[Main Page]]
was
saying as that, but interestingly the first [[:image: ]] tags was parsing
You mean [[Main Page]] didn't turn into a link while [[:Image:Foo.jpg]] did? Are you sure [[Main Page]] isn't a self-link?
$title =
$parser->parse($title,$wgTitle,ParserOptions::newFromUser($wgUser),false,false)->getText();
... however did. This is with MW 1.13.1.
However now the batch processes take forever, and the culprit is the "->parse" - it seems to take exponentially longer to run. internalParse
runs
quicker, so for the time being I have detected commandline functions and NS_SPECIAL pages and sent it that way (as I don't really care if the
pages
parse correctly or not there).
Are there any expected known limitations of internalParse? Should it
always
output the same as parse or are there certain cases which will never work with it?
Are you doing this inside a hook that's called by the parser? If so, you should not call $parser->parse() but use $parser->recursiveTagParse() instead (I don't know whether $parser->internalParse() is forbidden as well).
Roan Kattouw (Catrope)
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
wikitech-l@lists.wikimedia.org