A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 

208 рядки
4.9 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: invalid_newline
  42. label: invalid wikilink: newline as only content
  43. input: "[[\n]]"
  44. output: [Text(text="[[\n]]")]
  45. ---
  46. name: invalid_right_brace
  47. label: invalid wikilink: right brace
  48. input: "[[foo}b}a}r]]"
  49. output: [Text(text="[[foo}b}a}r]]")]
  50. ---
  51. name: invalid_left_brace
  52. label: invalid wikilink: left brace
  53. input: "[[foo{{[a}}]]"
  54. output: [Text(text="[[foo{{[a}}]]")]
  55. ---
  56. name: invalid_right_bracket
  57. label: invalid wikilink: right bracket
  58. input: "[[foo]bar]]"
  59. output: [Text(text="[[foo]bar]]")]
  60. ---
  61. name: invalid_left_bracket
  62. label: invalid wikilink: left bracket
  63. input: "[[foo[bar]]"
  64. output: [Text(text="[[foo[bar]]")]
  65. ---
  66. name: invalid_nested_text
  67. label: invalid wikilink: nested within the text of another
  68. input: "[[foo|[[bar]]]]"
  69. output: [Text(text="[[foo|"), WikilinkOpen(), Text(text="bar"), WikilinkClose(), Text(text="]]")]
  70. ---
  71. name: invalid_nested_text_2
  72. label: invalid wikilink: a wikilink nested within the text of another, with additional content
  73. input: "[[foo|a[[b]]c]]"
  74. output: [Text(text="[[foo|a"), WikilinkOpen(), Text(text="b"), WikilinkClose(), Text(text="c]]")]
  75. ---
  76. name: invalid_nested_title
  77. label: invalid wikilink: nested within the title of another
  78. input: "[[foo[[bar]]]]"
  79. output: [Text(text="[[foo"), WikilinkOpen(), Text(text="bar"), WikilinkClose(), Text(text="]]")]
  80. ---
  81. name: invalid_nested_title_and_text
  82. label: invalid wikilink: nested within the title of another, 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: invalid_left_angle_bracket
  92. label: invalid wikilink: left angle bracket
  93. input: "[[foo<bar]]"
  94. output: [Text(text="[[foo<bar]]")]
  95. ---
  96. name: invalid_right_angle_bracket
  97. label: invalid wikilink: right angle bracket
  98. input: "[[foo>bar]]"
  99. output: [Text(text="[[foo>bar]]")]
  100. ---
  101. name: invalid_newline_at_start
  102. label: invalid wikilink: newline at start of title
  103. input: "[[\nfoobar]]"
  104. output: [Text(text="[[\nfoobar]]")]
  105. ---
  106. name: invalid_newline_at_end
  107. label: invalid wikilink: newline at end of title
  108. input: "[[foobar\n]]"
  109. output: [Text(text="[[foobar\n]]")]
  110. ---
  111. name: incomplete_open_only
  112. label: incomplete wikilinks: just an open
  113. input: "[["
  114. output: [Text(text="[[")]
  115. ---
  116. name: incomplete_open_text
  117. label: incomplete wikilinks: an open with some text
  118. input: "[[foo"
  119. output: [Text(text="[[foo")]
  120. ---
  121. name: incomplete_open_text_pipe
  122. label: incomplete wikilinks: an open, text, then a pipe
  123. input: "[[foo|"
  124. output: [Text(text="[[foo|")]
  125. ---
  126. name: incomplete_open_pipe
  127. label: incomplete wikilinks: an open, then a pipe
  128. input: "[[|"
  129. output: [Text(text="[[|")]
  130. ---
  131. name: incomplete_open_pipe_text
  132. label: incomplete wikilinks: an open, then a pipe, then text
  133. input: "[[|foo"
  134. output: [Text(text="[[|foo")]
  135. ---
  136. name: incomplete_open_pipes_text
  137. label: incomplete wikilinks: a pipe, then text then two pipes
  138. input: "[[|f||"
  139. output: [Text(text="[[|f||")]
  140. ---
  141. name: incomplete_open_partial_close
  142. label: incomplete wikilinks: an open, then one right brace
  143. input: "[[{}"
  144. output: [Text(text="[[{}")]
  145. ---
  146. name: incomplete_preserve_previous
  147. label: incomplete wikilinks: a valid wikilink followed by an invalid one
  148. input: "[[foo]] [[bar"
  149. output: [WikilinkOpen(), Text(text="foo"), WikilinkClose(), Text(text=" [[bar")]