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

131 rinda
3.1 KiB

  1. name: blank
  2. label: argument with no content
  3. input: "{{{}}}"
  4. output: [ArgumentOpen(), ArgumentClose()]
  5. ---
  6. name: blank_with_default
  7. label: argument with no content but a pipe
  8. input: "{{{|}}}"
  9. output: [ArgumentOpen(), ArgumentSeparator(), ArgumentClose()]
  10. ---
  11. name: basic
  12. label: simplest type of argument
  13. input: "{{{argument}}}"
  14. output: [ArgumentOpen(), Text(text="argument"), ArgumentClose()]
  15. ---
  16. name: default
  17. label: argument with a default value
  18. input: "{{{foo|bar}}}"
  19. output: [ArgumentOpen(), Text(text="foo"), ArgumentSeparator(), Text(text="bar"), ArgumentClose()]
  20. ---
  21. name: blank_with_multiple_defaults
  22. label: no content, multiple pipes
  23. input: "{{{|||}}}"
  24. output: [ArgumentOpen(), ArgumentSeparator(), Text(text="||"), ArgumentClose()]
  25. ---
  26. name: multiple_defaults
  27. label: multiple values separated by pipes
  28. input: "{{{foo|bar|baz}}}"
  29. output: [ArgumentOpen(), Text(text="foo"), ArgumentSeparator(), Text(text="bar|baz"), ArgumentClose()]
  30. ---
  31. name: newline
  32. label: newline as only content
  33. input: "{{{\n}}}"
  34. output: [ArgumentOpen(), Text(text="\n"), ArgumentClose()]
  35. ---
  36. name: right_braces
  37. label: multiple } scattered throughout text
  38. input: "{{{foo}b}a}r}}}"
  39. output: [ArgumentOpen(), Text(text="foo}b}a}r"), ArgumentClose()]
  40. ---
  41. name: right_braces_default
  42. label: multiple } scattered throughout text, with a default value
  43. input: "{{{foo}b}|}a}r}}}"
  44. output: [ArgumentOpen(), Text(text="foo}b}"), ArgumentSeparator(), Text(text="}a}r"), ArgumentClose()]
  45. ---
  46. name: nested
  47. label: an argument nested within another argument
  48. input: "{{{{{{foo}}}|{{{bar}}}}}}"
  49. output: [ArgumentOpen(), ArgumentOpen(), Text(text="foo"), ArgumentClose(), ArgumentSeparator(), ArgumentOpen(), Text(text="bar"), ArgumentClose(), ArgumentClose()]
  50. ---
  51. name: invalid_braces
  52. label: invalid argument: multiple braces that are not part of a template or argument
  53. input: "{{{foo{{[a}}}}}"
  54. output: [Text(text="{{{foo{{[a}}}}}")]
  55. ---
  56. name: incomplete_open_only
  57. label: incomplete arguments: just an open
  58. input: "{{{"
  59. output: [Text(text="{{{")]
  60. ---
  61. name: incomplete_open_text
  62. label: incomplete arguments: an open with some text
  63. input: "{{{foo"
  64. output: [Text(text="{{{foo")]
  65. ---
  66. name: incomplete_open_text_pipe
  67. label: incomplete arguments: an open, text, then a pipe
  68. input: "{{{foo|"
  69. output: [Text(text="{{{foo|")]
  70. ---
  71. name: incomplete_open_pipe
  72. label: incomplete arguments: an open, then a pipe
  73. input: "{{{|"
  74. output: [Text(text="{{{|")]
  75. ---
  76. name: incomplete_open_pipe_text
  77. label: incomplete arguments: an open, then a pipe, then text
  78. input: "{{{|foo"
  79. output: [Text(text="{{{|foo")]
  80. ---
  81. name: incomplete_open_pipes_text
  82. label: incomplete arguments: a pipe, then text then two pipes
  83. input: "{{{|f||"
  84. output: [Text(text="{{{|f||")]
  85. ---
  86. name: incomplete_open_partial_close
  87. label: incomplete arguments: an open, then one right brace
  88. input: "{{{{}"
  89. output: [Text(text="{{{{}")]
  90. ---
  91. name: incomplete_preserve_previous
  92. label: incomplete arguments: a valid argument followed by an invalid one
  93. input: "{{{foo}}} {{{bar"
  94. output: [ArgumentOpen(), Text(text="foo"), ArgumentClose(), Text(text=" {{{bar")]