A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

wikilinks.mwtest 4.9 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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: "[[file:foo|[[bar]]]]"
  44. output: [WikilinkOpen(), Text(text="file: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: "[[file:foo|a[[b]]c]]"
  49. output: [WikilinkOpen(), Text(text="file: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_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")]