Last modified: 2014-07-18 18:18:34 UTC
The problem is that the expandtemplates API call returns with some unexpanded templates: Minimal Example: http://en.wikipedia.org/w/index.php?title=User:Volker.haas/TemplateExpansion&oldid=544039610 API Call (without revision info of article...): https://en.wikipedia.org/w/api.php?action=expandtemplates&format=jsonfm&text={{User:Volker.haas/TemplateExpansion}} Result: >{ > "expandtemplates": { > "*": "blub<ref>{{Structurae|id=s0015184|title=Padma >Bridge|nolink=1}}, [[Padma Bridge|Report on the official hearing on construction >progress]]<\/ref>\n\n== References ==\n<div class=\"reflist >references->column-count references-column-count-2\" style=\"-moz-column-count: >2; -webkit-column-count: 2; column-count: 2; list-style-type: decimal;\">\n<references group=\"\"><\/references><\/div>" > } >} This issue is criticial for the PDF rendering software (Extension:Collection and mwlib), since it now uses the API for expanding templates
Using the ApiSandbox: http://en.wikipedia.org/wiki/Special:ApiSandbox#action=expandtemplates&format=json&text=%7B%7BUser%3AVolker.haas%2FTemplateExpansion%7D%7D The result shows up {{cite web... I guess there is no recursion.
With action=parse&prop=text&page=User:Voker.haas/TemplateExpansion http://en.wikipedia.org/wiki/Special:ApiSandbox#action=parse&format=json&page=User%3AVolker.haas%2FTemplateExpansion&prop=text So I guess you want to use action=parse&prop=text&page= instead of action=expandtemplate.
Does the above call expand templates and give me mediawiki markup? If not, that's not what we want...
Ah no, that render them :-] Sorry.
Compare this with the behavior described on bug 28616.
(In reply to comment #5) > Compare this with the behavior described on bug 28616. http://de.wikipedia.org/w/api.php?action=expandtemplates&format=jsonfm&text=%7B%7B((%7D%7DVorlage%7B%7B!%7D%7DX%7B%7B))%7D%7D%20%3Cp%3Cincludeonly%2F%3Ere%3EX%3C%2Fpre%3E
The problem is that "expandtemplates" is a bit of a hack: it half-parses the wikitext to get new wikitext. But this half-parsing can't include calling tag hooks, because the tag hook returns HTML rather than wikitext. And it can't necessarily parse the text passed to the tag hook, because the tag hook might do almost anything with it (e.g. <syntaxhighlight> doesn't expand any templates, <ref> does, and it's theoretically possible to create a tag hook that would run inline Lua code or the like. So it just outputs the tag contents as-is. It sometimes breaks in other ways, too. Consider, for example, what it does to something like "{{#tag:ref|Ref A<ref>Ref B</ref>}}". Bug 28616 is similar: Special:ExpandTemplates half-parses the wikitext, and then parsed the half-parsed wikitext. This two-step parse can give different results.
*** Bug 50090 has been marked as a duplicate of this bug. ***
*** Bug 48872 has been marked as a duplicate of this bug. ***
*** Bug 53260 has been marked as a duplicate of this bug. ***