A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

257 linhas
7.8 KiB

  1. name: basic
  2. label: a basic tag with an open and close
  3. input: "<ref></ref>"
  4. output: [TagOpenOpen(showtag=True), Text(text="ref"), TagCloseOpen(padding=""), TagOpenClose(), Text(text="ref"), TagCloseClose()]
  5. ---
  6. name: basic_selfclosing
  7. label: a basic self-closing tag
  8. input: "<ref/>"
  9. output: [TagOpenOpen(showtag=True), Text(text="ref"), TagCloseSelfclose(padding="")]
  10. ---
  11. name: content
  12. label: a tag with some content in the middle
  13. input: "<ref>this is a reference</ref>"
  14. output: [TagOpenOpen(showtag=True), Text(text="ref"), TagCloseOpen(padding=""), Text(text="this is a reference"), TagOpenClose(), Text(text="ref"), TagCloseClose()]
  15. ---
  16. name: padded_open
  17. label: a tag with some padding in the open tag
  18. input: "<ref ></ref>"
  19. output: [TagOpenOpen(showtag=True), Text(text="ref"), TagCloseOpen(padding=" "), TagOpenClose(), Text(text="ref"), TagCloseClose()]
  20. ---
  21. name: padded_close
  22. label: a tag with some padding in the close tag
  23. input: "<ref></ref >"
  24. output: [TagOpenOpen(showtag=True), Text(text="ref"), TagCloseOpen(padding=""), TagOpenClose(), Text(text="ref "), TagCloseClose()]
  25. ---
  26. name: padded_selfclosing
  27. label: a self-closing tag with padding
  28. input: "<ref />"
  29. output: [TagOpenOpen(showtag=True), Text(text="ref"), TagCloseSelfclose(padding=" ")]
  30. ---
  31. name: attribute
  32. label: a tag with a single attribute
  33. input: "<ref name></ref>"
  34. output: [TagOpenOpen(showtag=True), Text(text="ref"), TagAttrStart(pad_first=" ", pad_before_eq="", pad_after_eq=""), Text(text="name"), TagCloseOpen(padding=""), TagOpenClose(), Text(text="ref"), TagCloseClose()]
  35. ---
  36. name: attribute_value
  37. label: a tag with a single attribute with a value
  38. input: "<ref name=foo></ref>"
  39. output: [TagOpenOpen(showtag=True), Text(text="ref"), TagAttrStart(pad_first=" ", pad_before_eq="", pad_after_eq=""), Text(text="name"), TagAttrEquals(), Text(text="foo"), TagCloseOpen(padding=""), TagOpenClose(), Text(text="ref"), TagCloseClose()]
  40. ---
  41. name: attribute_quoted
  42. label: a tag with a single quoted attribute
  43. input: "<ref name="foo"></ref>"
  44. output: [TagOpenOpen(showtag=True), Text(text="ref"), TagAttrStart(pad_first=" ", pad_before_eq="", pad_after_eq=""), Text(text="name"), TagAttrEquals(), TagAttrQuote(), Text(text="foo"), TagCloseOpen(padding=""), TagOpenClose(), Text(text="ref"), TagCloseClose()]
  45. ---
  46. name: attribute_hyphen
  47. label: a tag with a single attribute, containing a hyphen
  48. input: "<ref name=foo-bar></ref>"
  49. output: [TagOpenOpen(showtag=True), Text(text="ref"), TagAttrStart(pad_first=" ", pad_before_eq="", pad_after_eq=""), Text(text="name"), TagAttrEquals(), Text(text="foo-bar"), TagCloseOpen(padding=""), TagOpenClose(), Text(text="ref"), TagCloseClose()]
  50. ---
  51. name: attribute_quoted_hyphen
  52. label: a tag with a single quoted attribute, containing a hyphen
  53. input: "<ref name="foo-bar"></ref>"
  54. output: [TagOpenOpen(showtag=True), Text(text="ref"), TagAttrStart(pad_first=" ", pad_before_eq="", pad_after_eq=""), Text(text="name"), TagAttrEquals(), TagAttrQuote(), Text(text="foo-bar"), TagCloseOpen(padding=""), TagOpenClose(), Text(text="ref"), TagCloseClose()]
  55. ---
  56. name: attribute_selfclosing
  57. label: a self-closing tag with a single attribute
  58. input: "<ref name/>"
  59. output: [TagOpenOpen(showtag=True), Text(text="ref"), TagAttrStart(pad_first=" ", pad_before_eq="", pad_after_eq=""), Text(text="name"), TagCloseSelfclose(padding="")]
  60. ---
  61. name: attribute_selfclosing_value
  62. label: a self-closing tag with a single attribute with a value
  63. input: "<ref name=foo/>"
  64. output: [TagOpenOpen(showtag=True), Text(text="ref"), TagAttrStart(pad_first=" ", pad_before_eq="", pad_after_eq=""), Text(text="name"), TagAttrEquals(), Text(text="foo"), TagCloseSelfclose(padding="")]
  65. ---
  66. name: attribute_selfclosing_value_quoted
  67. label: a self-closing tag with a single quoted attribute
  68. input: "<ref name="foo"/>"
  69. output: [TagOpenOpen(showtag=True), Text(text="ref"), TagAttrStart(pad_first=" ", pad_before_eq="", pad_after_eq=""), Text(text="name"), TagAttrEquals(), TagAttrQuote(), Text(text="foo"), TagCloseSelfclose(padding="")]
  70. ---
  71. name: incomplete_lbracket
  72. label: incomplete tags: just a left bracket
  73. input: "<"
  74. output: [Text(text="<")]
  75. ---
  76. name: incomplete_lbracket_junk
  77. label: incomplete tags: just a left bracket, surrounded by stuff
  78. input: "foo<bar"
  79. output: [Text(text="foo<bar")]
  80. ---
  81. name: incomplete_unclosed_open
  82. label: incomplete tags: an unclosed open tag
  83. input: "junk <ref"
  84. output: [Text(text="junk <ref")]
  85. ---
  86. name: incomplete_unclosed_open_space
  87. label: incomplete tags: an unclosed open tag, space
  88. input: "junk <ref "
  89. output: [Text(text="junk <ref ")]
  90. ---
  91. name: incomplete_unclosed_open_unnamed_attr
  92. label: incomplete tags: an unclosed open tag, unnamed attribute
  93. input: "junk <ref name"
  94. output: [Text(text="junk <ref name")]
  95. ---
  96. name: incomplete_unclosed_open_attr_equals
  97. label: incomplete tags: an unclosed open tag, attribute, equal sign
  98. input: "junk <ref name="
  99. output: [Text(text="junk <ref name=")]
  100. ---
  101. name: incomplete_unclosed_open_attr_equals_quoted
  102. label: incomplete tags: an unclosed open tag, attribute, equal sign, quote
  103. input: "junk <ref name=""
  104. output: [Text(text="junk <ref name=\"")]
  105. ---
  106. name: incomplete_unclosed_open_attr
  107. label: incomplete tags: an unclosed open tag, attribute with a key/value
  108. input: "junk <ref name=foo"
  109. output: [Text(text="junk <ref name=foo")]
  110. ---
  111. name: incomplete_unclosed_open_attr_quoted
  112. label: incomplete tags: an unclosed open tag, attribute with a key/value, quoted
  113. input: "junk <ref name="foo""
  114. output: [Text(text="junk <ref name=\"foo\"")]
  115. ---
  116. name: incomplete_open
  117. label: incomplete tags: an open tag
  118. input: "junk <ref>"
  119. output: [Text(text="junk <ref>")]
  120. ---
  121. name: incomplete_open_unnamed_attr
  122. label: incomplete tags: an open tag, unnamed attribute
  123. input: "junk <ref name>"
  124. output: [Text(text="junk <ref name>")]
  125. ---
  126. name: incomplete_open_attr_equals
  127. label: incomplete tags: an open tag, attribute, equal sign
  128. input: "junk <ref name=>"
  129. output: [Text(text="junk <ref name=>")]
  130. ---
  131. name: incomplete_open_attr
  132. label: incomplete tags: an open tag, attribute with a key/value
  133. input: "junk <ref name=foo>"
  134. output: [Text(text="junk <ref name=foo>")]
  135. ---
  136. name: incomplete_open_attr_quoted
  137. label: incomplete tags: an open tag, attribute with a key/value, quoted
  138. input: "junk <ref name="foo">"
  139. output: [Text(text="junk <ref name=\"foo\">")]
  140. ---
  141. name: incomplete_open_text
  142. label: incomplete tags: an open tag, text
  143. input: "junk <ref>foo"
  144. output: [Text(text="junk <ref>foo")]
  145. ---
  146. name: incomplete_open_attr_text
  147. label: incomplete tags: an open tag, attribute with a key/value, text
  148. input: "junk <ref name=foo>bar"
  149. output: [Text(text="junk <ref name=foo>bar")]
  150. ---
  151. name: incomplete_open_text_lbracket
  152. label: incomplete tags: an open tag, text, left open bracket
  153. input: "junk <ref>bar<"
  154. output: [Text(text="junk <ref>bar<")]
  155. ---
  156. name: incomplete_open_text_lbracket_slash
  157. label: incomplete tags: an open tag, text, left bracket, slash
  158. input: "junk <ref>bar</"
  159. output: [Text(text="junk <ref>bar</")]
  160. ---
  161. name: incomplete_open_text_unclosed_close
  162. label: incomplete tags: an open tag, text, unclosed close
  163. input: "junk <ref>bar</ref"
  164. output: [Text(text="junk <ref>bar</ref")]
  165. ---
  166. name: incomplete_open_text_wrong_close
  167. label: incomplete tags: an open tag, text, wrong close
  168. input: "junk <ref>bar</span>"
  169. output: [Text(text="junk <ref>bar</span>")]
  170. ---
  171. name: incomplete_no_tag_name_open
  172. label: incomplete tags: no tag name within brackets; just an open
  173. input: "junk <>"
  174. output: [Text(text="junk <>")]
  175. ---
  176. name: incomplete_no_tag_name_selfclosing
  177. label: incomplete tags: no tag name within brackets; self-closing
  178. input: "junk < />"
  179. output: [Text(text="junk < />")]
  180. ---
  181. name: incomplete_no_tag_name_open_close
  182. label: incomplete tags: no tag name within brackets; open and close
  183. input: "junk <></>"
  184. output: [Text(text="junk <></>")]