A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

180 rindas
4.3 KiB

  1. name: blank
  2. label: wikilink with no content
  3. input: "[[]]"
  4. output: [WikilinkOpen(), WikilinkClose()]
  5. ---
  6. name: blank_with_text
  7. label: wikilink with no content but a pipe
  8. input: "[[|]]"
  9. output: [WikilinkOpen(), WikilinkSeparator(), WikilinkClose()]
  10. ---
  11. name: basic
  12. label: simplest type of wikilink
  13. input: "[[wikilink]]"
  14. output: [WikilinkOpen(), Text(text="wikilink"), WikilinkClose()]
  15. ---
  16. name: with_text
  17. label: wikilink with a text value
  18. input: "[[foo|bar]]"
  19. output: [WikilinkOpen(), Text(text="foo"), WikilinkSeparator(), Text(text="bar"), WikilinkClose()]
  20. ---
  21. name: blank_with_multiple_texts
  22. label: no content, multiple pipes
  23. input: "[[|||]]"
  24. output: [WikilinkOpen(), WikilinkSeparator(), Text(text="||"), WikilinkClose()]
  25. ---
  26. name: multiple_texts
  27. label: multiple text values separated by pipes
  28. input: "[[foo|bar|baz]]"
  29. output: [WikilinkOpen(), Text(text="foo"), WikilinkSeparator(), Text(text="bar|baz"), WikilinkClose()]
  30. ---
  31. name: newline_text
  32. label: a newline in the middle of the text
  33. input: "[[foo|foo\nbar]]"
  34. output: [WikilinkOpen(), Text(text="foo"), WikilinkSeparator(), Text(text="foo\nbar"), WikilinkClose()]
  35. ---
  36. name: bracket_text
  37. label: a left bracket in the middle of the text
  38. input: "[[foo|bar[baz]]"
  39. output: [WikilinkOpen(), Text(text="foo"), WikilinkSeparator(), Text(text="bar[baz"), WikilinkClose()]
  40. ---
  41. name: nested
  42. label: a wikilink nested within another
  43. input: "[[foo|[[bar]]]]"
  44. output: [WikilinkOpen(), Text(text="foo"), WikilinkSeparator(), WikilinkOpen(), Text(text="bar"), WikilinkClose(), WikilinkClose()]
  45. ---
  46. name: nested_padding
  47. label: a wikilink nested within another, separated by other data
  48. input: "[[foo|a[[b]]c]]"
  49. output: [WikilinkOpen(), Text(text="foo"), WikilinkSeparator(), Text(text="a"), WikilinkOpen(), Text(text="b"), WikilinkClose(), Text(text="c"), WikilinkClose()]
  50. ---
  51. name: invalid_newline
  52. label: invalid wikilink: newline as only content
  53. input: "[[\n]]"
  54. output: [Text(text="[[\n]]")]
  55. ---
  56. name: invalid_right_brace
  57. label: invalid wikilink: right brace
  58. input: "[[foo}b}a}r]]"
  59. output: [Text(text="[[foo}b}a}r]]")]
  60. ---
  61. name: invalid_left_brace
  62. label: invalid wikilink: left brace
  63. input: "[[foo{{[a}}]]"
  64. output: [Text(text="[[foo{{[a}}]]")]
  65. ---
  66. name: invalid_right_bracket
  67. label: invalid wikilink: right bracket
  68. input: "[[foo]bar]]"
  69. output: [Text(text="[[foo]bar]]")]
  70. ---
  71. name: invalid_left_bracket
  72. label: invalid wikilink: left bracket
  73. input: "[[foo[bar]]"
  74. output: [Text(text="[[foo[bar]]")]
  75. ---
  76. name: invalid_nested
  77. label: invalid wikilink: trying to nest in the wrong context
  78. input: "[[foo[[bar]]]]"
  79. output: [Text(text="[[foo"), WikilinkOpen(), Text(text="bar"), WikilinkClose(), Text(text="]]")]
  80. ---
  81. name: invalid_nested_padding
  82. label: invalid wikilink: trying to nest in the wrong context, with a text param
  83. input: "[[foo[[bar]]|baz]]"
  84. output: [Text(text="[[foo"), WikilinkOpen(), Text(text="bar"), WikilinkClose(), Text(text="|baz]]")]
  85. ---
  86. name: invalid_nested_no_close
  87. label: invalid wikilink: a wikilink nested within the value of another, missing a pair of closing brackets
  88. input: "[[foo|[[bar]]"
  89. output: [Text(text="[[foo|"), WikilinkOpen(), Text(text="bar"), WikilinkClose()]
  90. ---
  91. name: incomplete_open_only
  92. label: incomplete wikilinks: just an open
  93. input: "[["
  94. output: [Text(text="[[")]
  95. ---
  96. name: incomplete_open_text
  97. label: incomplete wikilinks: an open with some text
  98. input: "[[foo"
  99. output: [Text(text="[[foo")]
  100. ---
  101. name: incomplete_open_text_pipe
  102. label: incomplete wikilinks: an open, text, then a pipe
  103. input: "[[foo|"
  104. output: [Text(text="[[foo|")]
  105. ---
  106. name: incomplete_open_pipe
  107. label: incomplete wikilinks: an open, then a pipe
  108. input: "[[|"
  109. output: [Text(text="[[|")]
  110. ---
  111. name: incomplete_open_pipe_text
  112. label: incomplete wikilinks: an open, then a pipe, then text
  113. input: "[[|foo"
  114. output: [Text(text="[[|foo")]
  115. ---
  116. name: incomplete_open_pipes_text
  117. label: incomplete wikilinks: a pipe, then text then two pipes
  118. input: "[[|f||"
  119. output: [Text(text="[[|f||")]
  120. ---
  121. name: incomplete_open_partial_close
  122. label: incomplete wikilinks: an open, then one right brace
  123. input: "[[{}"
  124. output: [Text(text="[[{}")]
  125. ---
  126. name: incomplete_preserve_previous
  127. label: incomplete wikilinks: a valid wikilink followed by an invalid one
  128. input: "[[foo]] [[bar"
  129. output: [WikilinkOpen(), Text(text="foo"), WikilinkClose(), Text(text=" [[bar")]