A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

15 lines
385 B

  1. import mwparserfromhell
  2. text = "foo {{spam|eggs}} bar"
  3. code = mwparserfromhell.parse(text)
  4. template = code.filter_templates()[0]
  5. template.name
  6. template.params
  7. template.params[0].value
  8. template.params[0].name
  9. template.params[0].showkey
  10. template.params[0].showkey = True
  11. template.params[0].name = "apples"
  12. code
  13. template.add("pears", "{{plums}}")
  14. code.filter_templates(recursive=True)