pythonwikipediawikitext

Expand templates to text in wikipedia


I have some custom wikitext(which also includes templates) and need to convert to text. To do this, I use wikiexpand.

In the README file it is indicated:

Modules written in Lua and executed using {{#invoke:}} are not recognised, but can be replaced by implementing callable templates (that is, functions that render Wikicode)

The documentation in wikiexpand.expand.templates.TemplateStore.callable_templates is not very explicit.

Would it be possible to help me by giving me an example implementation?

For example, for the following wikicode:

{{ISBN|978-2-84066-599-1}}
{{Date de naissance|11|novembre|1866}}

Solution

  • I guess what the documentation says is it cannot expand lua templates, but only 'normal' wikicode ones.

    A solution could be tu use the pre-lua versions of templates, like the wikicode of the 2012 version of {{Date de naissance}}.

    If it concerns wp.fr, you'll probably have better and quicker answers on Discussion Projet:Modèle.