wikitextparser icon indicating copy to clipboard operation
wikitextparser copied to clipboard

[Feature request] Add wikiexpand support to expand templates

Open cbrender-deploy1 opened this issue 2 years ago • 1 comments

Thank you very much for your work in wikitextparser! I've been using wikitextparser for a few hours to convert wikitext to Markdown, and I've already made substantial progress using your tool.

That said, I found this tool called wikiexpand (Source code), which basically expands transclusions and magic words, thus allowing for completely offline parsing of templates. I would like to request adding it in wikitextparser.

This way, if we have a list of all templates needed for a page, we can tell it to recursively expand all the templates, instead of calling Special:ExpandTemplates.

Here are some things to note:

  • wikiexpand is dependent on mwparserfromhell, so the code must be ported/adopted to wikitextparser to remove the dependency
  • even though it still works, wikiexpand is a bit dated and unmaintained
  • a template store object to store the source code for all the templates

What do you think?

Thanks in advance!

cbrender-deploy1 avatar May 06 '23 03:05 cbrender-deploy1

Thanks for the feedback! I actually had something like this in mind when I started _config.py, but never found the time to actually go through with it. It is a lot of work. Requires evaluating parser functions and magic words, handling localization for namespaces and functions, etc. I don't think I can continue to work on it with my current limited time.

I would encourage anyone interested in working on such a feature/package to create a separate package, similar to how wikiexpand authors have done for mwparserfromhell. Maybe create a fork if that helps. At this stage, mixing it with wikitextparser might hinder your work due to my lack of time in engaging with the new features. Please let me know how things go and if there are any improvement in wikitextparser's API that could help.

5j9 avatar May 19 '23 11:05 5j9