Hello everyone,
I am trying to obtain through a web request from an application i'm working on the raw wikitext version of an arbitrary Wikipedia article. However, i prefer the templates to be already expanded into their constituent wikitext and/or HTML, and from what i read on the Wikimedia API documentation this should be done by appending "&templates=expand" to the query string; thus, if I wanted the English version of the article about Barcelona in wikitext with template expansion, the URL would be: http://en.wikipedia.org/w/index.php?action=raw&title=Barcelona&templ.... However, i soon found out that not all of the templates are actually expanded, the exception being those templates enclosed in wiki tags, which are left unexpanded (perhaps the most common example being {{cite ...}} templates inside <ref></ref> tags).
I eventually learned that the API provides an individual template expansion module, accessible through ...api.php?action=expandtemplates&text={{template_to_expand}} . This was not really the solution I hoped for actually, since it is impractical for long templates (i assume there's a limit imposed on that query string) and for each of the unexpanded template i'd have to send a separate request to the server, which could prove highly expensive in terms of performance. I've also seen there's the special Wikipedia template expansion page (http://en.wikipedia.org/wiki/Special:ExpandTemplates ), but I don't know if and how I could access its functionality from my application and how I could use it for several templates at once.
Could anyone please suggest a solution for expanding all the templates or at least a viable workaround for this issue ? Thanks in advance, Gabriel S.
On Thu, Oct 14, 2010 at 4:52 PM, Gabriel Sandor gabi.t.sandor@gmail.com wrote:
However, i soon found out that not all of the templates are actually expanded, the exception being those templates enclosed in wiki tags, which are left unexpanded (perhaps the most common example being {{cite ...}} templates inside <ref></ref> tags).
It appears to be that this happens indeed for <ref> tags. These tags are part of extension Cite. Cite normally takes those tags, removes them an relocates them to the location of the <references /> tag.
I'm guessing here, but what I think happens is that extension Cite only does this in the parsing stage, so in the preprocessing stage nothing is processed. Perhaps somebody with parser and Cite knowledge can elaborate a bit more on this?
Bryan
Bryan Tong Minh wrote:
On Thu, Oct 14, 2010 at 4:52 PM, Gabriel Sandor gabi.t.sandor@gmail.com wrote:
However, i soon found out that not all of the templates are actually expanded, the exception being those templates enclosed in wiki tags, which are left unexpanded (perhaps the most common example being {{cite ...}} templates inside <ref></ref> tags).
It appears to be that this happens indeed for <ref> tags. These tags are part of extension Cite. Cite normally takes those tags, removes them an relocates them to the location of the <references /> tag.
I'm guessing here, but what I think happens is that extension Cite only does this in the parsing stage, so in the preprocessing stage nothing is processed. Perhaps somebody with parser and Cite knowledge can elaborate a bit more on this?
Bryan
You are right. Tag extensions aren't expanded by the preprocessor. Instead, when you run the tag function, the tags which contain wikitext call expandTemplates() on the content with the same parser and frame.
mediawiki-l@lists.wikimedia.org