5j9 / wikitextparser

A Python library to parse MediaWiki WikiText
GNU General Public License v3.0
289 stars 22 forks source link

[Feature request] Add wikiexpand support to expand templates #114

Open cbrender-deploy1 opened 1 year ago

cbrender-deploy1 commented 1 year ago

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:

What do you think?

Thanks in advance!

5j9 commented 1 year ago

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.