-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Convert Wikicode to XML #161
Comments
Do you mean the raw wikitext in the wiki source looks like XML? Or, the mwparserfromhell generated tree looks like XML? |
Sorry, let me give you a concrete example. This is the source:
I would like to turn the links ( So each of these links should be turned into something like: When I pass the source code to the Ideally, I would be able to export everything as one string in the end that represents an XML document. |
Would you be happy with it converted to HTML ? |
Well, it depends on how this HTML would look like :-) What would be the easiest way to do the thing I want? Are there other tools I could use? |
I believe that parsoid can be used as a library (without the web service) or command line tool, so that could be enough to give you a HTML version. |
mwparserfromhell can't parse the |
You can retrieve the articles as HTML using the official API. |
I figured out a solution that works for me by iterating over the nodes (recursively) and looking at their type (`isinstance). Depending on the type of the node, I write the desired XML representation to a file. Actually, I just have to generate the doctype, the root elements (opening and closing) and handle internal and external links specially. The rest already looks like XML. |
Is there an easy way to convert Wikicode to XML using
mwparserfromhell
?In fact, the mw code I am dealing with already looks like XML except for the links.
Can I provide a mapping for these wiki-links so they get turned into XML?
Could I use the
builder
to do so applying_handle_wikilink
(https://mwparserfromhell.readthedocs.io/en/latest/api/mwparserfromhell.parser.html#module-mwparserfromhell.parser.builder)?The text was updated successfully, but these errors were encountered: