A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/

comments.mwtest 1.0 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. name: blank
  2. label: a blank comment
  3. input: "<!---->"
  4. output: [CommentStart(), CommentEnd()]
  5. ---
  6. name: basic
  7. label: a basic comment
  8. input: "<!-- comment -->"
  9. output: [CommentStart(), Text(text=" comment "), CommentEnd()]
  10. ---
  11. name: tons_of_nonsense
  12. label: a comment with tons of ignorable garbage in it
  13. input: "<!-- foo{{bar}}[[basé\n\n]{}{}{}{}]{{{{{{haha{{--a>aa<!--aa -->"
  14. output: [CommentStart(), Text(text=" foo{{bar}}[[basé\n\n]{}{}{}{}]{{{{{{haha{{--a>aa<!--aa "), CommentEnd()]
  15. ---
  16. name: incomplete_blank
  17. label: a comment that doesn't close
  18. input: "<!--"
  19. output: [Text(text="<!--")]
  20. ---
  21. name: incomplete_text
  22. label: a comment that doesn't close, with text
  23. input: "<!-- foo"
  24. output: [Text(text="<!-- foo")]
  25. ---
  26. name: incomplete_partial_close
  27. label: a comment that doesn't close, with a partial close
  28. input: "<!-- foo --\x01>"
  29. output: [Text(text="<!-- foo --\x01>")]
  30. ---
  31. name: incomplete_part_only
  32. label: a comment that only has a < and !
  33. input: "<!foo"
  34. output: [Text(text="<!foo")]