A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

368 行
15 KiB

  1. name: no_params
  2. label: simplest type of template
  3. input: "{{template}}"
  4. output: [TemplateOpen(), Text(text="template"), TemplateClose()]
  5. ---
  6. name: one_param_unnamed
  7. label: basic template with one unnamed parameter
  8. input: "{{foo|bar}}"
  9. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar"), TemplateClose()]
  10. ---
  11. name: one_param_named
  12. label: basic template with one named parameter
  13. input: "{{foo|bar=baz}}"
  14. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar"), TemplateParamEquals(), Text(text="baz"), TemplateClose()]
  15. ---
  16. name: multiple_unnamed_params
  17. label: basic template with multiple unnamed parameters
  18. input: "{{foo|bar|baz|biz|buzz}}"
  19. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar"), TemplateParamSeparator(), Text(text="baz"), TemplateParamSeparator(), Text(text="biz"), TemplateParamSeparator(), Text(text="buzz"), TemplateClose()]
  20. ---
  21. name: multiple_named_params
  22. label: basic template with multiple named parameters
  23. input: "{{foo|bar=baz|biz=buzz|buff=baff|usr=bin}}"
  24. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar"), TemplateParamEquals(), Text(text="baz"), TemplateParamSeparator(), Text(text="biz"), TemplateParamEquals(), Text(text="buzz"), TemplateParamSeparator(), Text(text="buff"), TemplateParamEquals(), Text(text="baff"), TemplateParamSeparator(), Text(text="usr"), TemplateParamEquals(), Text(text="bin"), TemplateClose()]
  25. ---
  26. name: multiple_mixed_params
  27. label: basic template with multiple unnamed/named parameters
  28. input: "{{foo|bar=baz|biz|buzz=buff|usr|bin}}"
  29. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar"), TemplateParamEquals(), Text(text="baz"), TemplateParamSeparator(), Text(text="biz"), TemplateParamSeparator(), Text(text="buzz"), TemplateParamEquals(), Text(text="buff"), TemplateParamSeparator(), Text(text="usr"), TemplateParamSeparator(), Text(text="bin"), TemplateClose()]
  30. ---
  31. name: multiple_mixed_params2
  32. label: basic template with multiple unnamed/named parameters in another order
  33. input: "{{foo|bar|baz|biz=buzz|buff=baff|usr=bin}}"
  34. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar"), TemplateParamSeparator(), Text(text="baz"), TemplateParamSeparator(), Text(text="biz"), TemplateParamEquals(), Text(text="buzz"), TemplateParamSeparator(), Text(text="buff"), TemplateParamEquals(), Text(text="baff"), TemplateParamSeparator(), Text(text="usr"), TemplateParamEquals(), Text(text="bin"), TemplateClose()]
  35. ---
  36. name: nested_unnamed_param
  37. label: nested template as an unnamed parameter
  38. input: "{{foo|{{bar}}}}"
  39. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateClose()]
  40. ---
  41. name: nested_named_param_value
  42. label: nested template as a parameter value with a named parameter
  43. input: "{{foo|bar={{baz}}}}"
  44. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar"), TemplateParamEquals(), TemplateOpen(), Text(text="baz"), TemplateClose(), TemplateClose()]
  45. ---
  46. name: nested_named_param_name_and_value
  47. label: nested templates as a parameter name and value
  48. input: "{{foo|{{bar}}={{baz}}}}"
  49. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateParamEquals(), TemplateOpen(), Text(text="baz"), TemplateClose(), TemplateClose()]
  50. ---
  51. name: nested_name_start
  52. label: nested template at the beginning of a template name
  53. input: "{{{{foo}}bar}}"
  54. output: [TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), Text(text="bar"), TemplateClose()]
  55. ---
  56. name: nested_name_start_unnamed_param
  57. label: nested template at the beginning of a template name and as an unnamed parameter
  58. input: "{{{{foo}}bar|{{baz}}}}"
  59. output: [TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), Text(text="bar"), TemplateParamSeparator(), TemplateOpen(), Text(text="baz"), TemplateClose(), TemplateClose()]
  60. ---
  61. name: nested_name_start_named_param_value
  62. label: nested template at the beginning of a template name and as a parameter value with a named parameter
  63. input: "{{{{foo}}bar|baz={{biz}}}}"
  64. output: [TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), Text(text="bar"), TemplateParamSeparator(), Text(text="baz"), TemplateParamEquals(), TemplateOpen(), Text(text="biz"), TemplateClose(), TemplateClose()]
  65. ---
  66. name: nested_name_start_named_param_name_and_value
  67. label: nested template at the beginning of a template name and as a parameter name and value
  68. input: "{{{{foo}}bar|{{baz}}={{biz}}}}"
  69. output: [TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), Text(text="bar"), TemplateParamSeparator(), TemplateOpen(), Text(text="baz"), TemplateClose(), TemplateParamEquals(), TemplateOpen(), Text(text="biz"), TemplateClose(), TemplateClose()]
  70. ---
  71. name: nested_name_end
  72. label: nested template at the end of a template name
  73. input: "{{foo{{bar}}}}"
  74. output: [TemplateOpen(), Text(text="foo"), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateClose()]
  75. ---
  76. name: nested_name_end_unnamed_param
  77. label: nested template at the end of a template name and as an unnamed parameter
  78. input: "{{foo{{bar}}|{{baz}}}}"
  79. output: [TemplateOpen(), Text(text="foo"), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateParamSeparator(), TemplateOpen(), Text(text="baz"), TemplateClose(), TemplateClose()]
  80. ---
  81. name: nested_name_end_named_param_value
  82. label: nested template at the end of a template name and as a parameter value with a named parameter
  83. input: "{{foo{{bar}}|baz={{biz}}}}"
  84. output: [TemplateOpen(), Text(text="foo"), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateParamSeparator(), Text(text="baz"), TemplateParamEquals(), TemplateOpen(), Text(text="biz"), TemplateClose(), TemplateClose()]
  85. ---
  86. name: nested_name_end_named_param_name_and_value
  87. label: nested template at the end of a template name and as a parameter name and value
  88. input: "{{foo{{bar}}|{{baz}}={{biz}}}}"
  89. output: [TemplateOpen(), Text(text="foo"), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateParamSeparator(), TemplateOpen(), Text(text="baz"), TemplateClose(), TemplateParamEquals(), TemplateOpen(), Text(text="biz"), TemplateClose(), TemplateClose()]
  90. ---
  91. name: nested_name_mid
  92. label: nested template in the middle of a template name
  93. input: "{{foo{{bar}}baz}}"
  94. output: [TemplateOpen(), Text(text="foo"), TemplateOpen(), Text(text="bar"), TemplateClose(), Text(text="baz"), TemplateClose()]
  95. ---
  96. name: nested_name_mid_unnamed_param
  97. label: nested template in the middle of a template name and as an unnamed parameter
  98. input: "{{foo{{bar}}baz|{{biz}}}}"
  99. output: [TemplateOpen(), Text(text="foo"), TemplateOpen(), Text(text="bar"), TemplateClose(), Text(text="baz"), TemplateParamSeparator(), TemplateOpen(), Text(text="biz"), TemplateClose(), TemplateClose()]
  100. ---
  101. name: nested_name_mid_named_param_value
  102. label: nested template in the middle of a template name and as a parameter value with a named parameter
  103. input: "{{foo{{bar}}baz|biz={{buzz}}}}"
  104. output: [TemplateOpen(), Text(text="foo"), TemplateOpen(), Text(text="bar"), TemplateClose(), Text(text="baz"), TemplateParamSeparator(), Text(text="biz"), TemplateParamEquals(), TemplateOpen(), Text(text="buzz"), TemplateClose(), TemplateClose()]
  105. ---
  106. name: nested_name_mid_named_param_name_and_value
  107. label: nested template in the middle of a template name and as a parameter name and value
  108. input: "{{foo{{bar}}baz|{{biz}}={{buzz}}}}"
  109. output: [TemplateOpen(), Text(text="foo"), TemplateOpen(), Text(text="bar"), TemplateClose(), Text(text="baz"), TemplateParamSeparator(), TemplateOpen(), Text(text="biz"), TemplateClose(), TemplateParamEquals(), TemplateOpen(), Text(text="buzz"), TemplateClose(), TemplateClose()]
  110. ---
  111. name: nested_name_start_end
  112. label: nested template at the beginning and end of a template name
  113. input: "{{{{foo}}{{bar}}}}"
  114. output: [TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateClose()]
  115. ---
  116. name: nested_name_start_end_unnamed_param
  117. label: nested template at the beginning and end of a template name and as an unnamed parameter
  118. input: "{{{{foo}}{{bar}}|{{baz}}}}"
  119. output: [TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateParamSeparator(), TemplateOpen(), Text(text="baz"), TemplateClose(), TemplateClose()]
  120. ---
  121. name: nested_name_start_end_named_param_value
  122. label: nested template at the beginning and end of a template name and as a parameter value with a named parameter
  123. input: "{{{{foo}}{{bar}}|baz={{biz}}}}"
  124. output: [TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateParamSeparator(), Text(text="baz"), TemplateParamEquals(), TemplateOpen(), Text(text="biz"), TemplateClose(), TemplateClose()]
  125. ---
  126. name: nested_name_start_end_named_param_name_and_value
  127. label: nested template at the beginning and end of a template name and as a parameter name and value
  128. input: "{{{{foo}}{{bar}}|{{baz}}={{biz}}}}"
  129. output: [TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateParamSeparator(), TemplateOpen(), Text(text="baz"), TemplateClose(), TemplateParamEquals(), TemplateOpen(), Text(text="biz"), TemplateClose(), TemplateClose()]
  130. ---
  131. name: nested_names_multiple
  132. label: multiple nested templates within nested templates
  133. input: "{{{{{{{{foo}}bar}}baz}}biz}}"
  134. output: [TemplateOpen(), TemplateOpen(), TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), Text(text="bar"), TemplateClose(), Text(text="baz"), TemplateClose(), Text(text="biz"), TemplateClose()]
  135. ---
  136. name: nested_names_multiple_unnamed_param
  137. label: multiple nested templates within nested templates with a nested unnamed parameter
  138. input: "{{{{{{{{foo}}bar}}baz}}biz|{{buzz}}}}"
  139. output: [TemplateOpen(), TemplateOpen(), TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), Text(text="bar"), TemplateClose(), Text(text="baz"), TemplateClose(), Text(text="biz"), TemplateParamSeparator(), TemplateOpen(), Text(text="buzz"), TemplateClose(), TemplateClose()]
  140. ---
  141. name: nested_names_multiple_named_param_value
  142. label: multiple nested templates within nested templates with a nested parameter value in a named parameter
  143. input: "{{{{{{{{foo}}bar}}baz}}biz|buzz={{bin}}}}"
  144. output: [TemplateOpen(), TemplateOpen(), TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), Text(text="bar"), TemplateClose(), Text(text="baz"), TemplateClose(), Text(text="biz"), TemplateParamSeparator(), Text(text="buzz"), TemplateParamEquals(), TemplateOpen(), Text(text="bin"), TemplateClose(), TemplateClose()]
  145. ---
  146. name: nested_names_multiple_named_param_name_and_value
  147. label: multiple nested templates within nested templates with a nested parameter name and value
  148. input: "{{{{{{{{foo}}bar}}baz}}biz|{{buzz}}={{bin}}}}"
  149. output: [TemplateOpen(), TemplateOpen(), TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), Text(text="bar"), TemplateClose(), Text(text="baz"), TemplateClose(), Text(text="biz"), TemplateParamSeparator(), TemplateOpen(), Text(text="buzz"), TemplateClose(), TemplateParamEquals(), TemplateOpen(), Text(text="bin"), TemplateClose(), TemplateClose()]
  150. ---
  151. name: mixed_nested_templates
  152. label: mixed assortment of nested templates within template names, parameter names, and values
  153. input: "{{{{{{{{foo}}bar|baz=biz}}buzz}}usr|{{bin}}}}"
  154. output: [TemplateOpen(), TemplateOpen(), TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), Text(text="bar"), TemplateParamSeparator(), Text(text="baz"), TemplateParamEquals(), Text(text="biz"), TemplateClose(), Text(text="buzz"), TemplateClose(), Text(text="usr"), TemplateParamSeparator(), TemplateOpen(), Text(text="bin"), TemplateClose(), TemplateClose()]
  155. ---
  156. name: newline_start
  157. label: a newline at the start of a template name
  158. input: "{{\nfoobar}}"
  159. output: [TemplateOpen(), Text(text="\nfoobar"), TemplateClose()]
  160. ---
  161. name: newline_end
  162. label: a newline at the end of a template name
  163. input: "{{foobar\n}}"
  164. output: [TemplateOpen(), Text(text="foobar\n"), TemplateClose()]
  165. ---
  166. name: newline_start_end
  167. label: a newline at the start and end of a template name
  168. input: "{{\nfoobar\n}}"
  169. output: [TemplateOpen(), Text(text="\nfoobar\n"), TemplateClose()]
  170. ---
  171. name: newline_mid
  172. label: a newline at the middle of a template name
  173. input: "{{foo\nbar}}"
  174. output: [Text(text="{{foo\nbar}}")]
  175. ---
  176. name: newline_start_mid
  177. label: a newline at the start and middle of a template name
  178. input: "{{\nfoo\nbar}}"
  179. output: [Text(text="{{\nfoo\nbar}}")]
  180. ---
  181. name: newline_mid_end
  182. label: a newline at the middle and end of a template name
  183. input: "{{foo\nbar\n}}"
  184. output: [Text(text="{{foo\nbar\n}}")]
  185. ---
  186. name: newline_start_mid_end
  187. label: a newline at the start, middle, and end of a template name
  188. input: "{{\nfoo\nbar\n}}"
  189. output: [Text(text="{{\nfoo\nbar\n}}")]
  190. ---
  191. name: incomplete_tests
  192. "{{foo|\nbar}}"
  193. "{{foo|bar\n}}"
  194. "{{foo|\nbar\n}}"
  195. "{{foo|\nb\nar}}"
  196. "{{foo|b\nar\n}}"
  197. "{{foo|\nb\nar\n}}"
  198. "{{\nfoo|\nbar}}"
  199. "{{\nfoo|bar\n}}"
  200. "{{\nfoo|\nbar\n}}"
  201. "{{\nfoo|\nb\nar}}"
  202. "{{\nfoo|b\nar\n}}"
  203. "{{\nfoo|\nb\nar\n}}"
  204. "{{foo\n|\nbar}}"
  205. "{{foo\n|bar\n}}"
  206. "{{foo\n|\nbar\n}}"
  207. "{{foo\n|\nb\nar}}"
  208. "{{foo\n|b\nar\n}}"
  209. "{{foo\n|\nb\nar\n}}"
  210. "{{\nfoo\n|\nbar}}"
  211. "{{\nfoo\n|bar\n}}"
  212. "{{\nfoo\n|\nbar\n}}"
  213. "{{\nfoo\n|\nb\nar}}"
  214. "{{\nfoo\n|b\nar\n}}"
  215. "{{\nfoo\n|\nb\nar\n}}"
  216. "{{f\noo|\nbar}}"
  217. "{{\nf\noo|\nbar}}"
  218. "{{f\noo\n|\nbar}}"
  219. "{{\nf\noo\n|\nbar}}"
  220. "{{foo|1=\nbar}}"
  221. "{{foo|1=bar\n}}"
  222. "{{foo|1=\nbar\n}}"
  223. "{{foo|1=\nb\nar}}"
  224. "{{foo|1=b\nar\n}}"
  225. "{{foo|1=\nb\nar\n}}"
  226. "{{foo|\nbar=baz}}"
  227. "{{foo|bar\n=baz}}"
  228. "{{foo|\nbar\n=baz}}"
  229. "{{foo|\nb\nar=baz}}"
  230. "{{foo|b\nar\n=baz}}"
  231. "{{foo|\nb\nar\n=baz}}"
  232. "{{foo|\nbar=baz\n}}"
  233. "{{foo|bar\n=baz\n}}"
  234. "{{foo|\nbar\n=baz\n}}"
  235. "{{foo|\nb\nar=baz\n}}"
  236. "{{foo|b\nar\n=baz\n}}"
  237. "{{foo|\nb\nar\n=baz\n}}"
  238. "{{foo|\nbar=\nbaz}}"
  239. "{{foo|bar\n=\nbaz}}"
  240. "{{foo|\nbar\n=\nbaz}}"
  241. "{{foo|\nb\nar=\nbaz}}"
  242. "{{foo|b\nar\n=\nbaz}}"
  243. "{{foo|\nb\nar\n=\nbaz}}"
  244. "{{foo|\nbar=\nbaz\n}}"
  245. "{{foo|bar\n=\nbaz\n}}"
  246. "{{foo|\nbar\n=\nbaz\n}}"
  247. "{{foo|\nb\nar=\nbaz\n}}"
  248. "{{foo|b\nar\n=\nbaz\n}}"
  249. "{{foo|\nb\nar\n=\nbaz\n}}"
  250. "{{foo|\nbar=ba\nz}}"
  251. "{{foo|bar\n=ba\nz}}"
  252. "{{foo|\nbar\n=ba\nz}}"
  253. "{{foo|\nb\nar=ba\nz}}"
  254. "{{foo|b\nar\n=ba\nz}}"
  255. "{{foo|\nb\nar\n=ba\nz}}"
  256. "{{\nfoo\n|\nbar\n=\nb\naz\n|\nb\nuz\n}}"
  257. "{{\nfoo\n|\nb\nar\n|\nbaz\n=\nb\nuz\n}}"
  258. "{{\nfoo\n|\n{{\nbar\n|\nbaz\n=\nb\niz\n}}\n=\nb\nuzz\n}}"
  259. "{{foo{bar}}"
  260. "{{foo}bar}}"
  261. "{{{foobar}}"
  262. "{{foo{b{ar}}"
  263. "{{foo[bar}}"
  264. "{{foo]bar}}"
  265. "{{[foobar}}"
  266. "{{foobar]}}"
  267. "{{foo|ba{r}}"
  268. "{{foo|ba{r}}}"
  269. "{{foo|ba{r}=baz}}"
  270. "{{foo|ba[r]}}"
  271. "{{foobar"
  272. "{{foobar}"
  273. "{{foobar|"
  274. "{{foo|bar"
  275. "{{foo|bar|"
  276. "{{foo|bar="
  277. "{{foo|bar=|"
  278. "{{foo|bar=baz"
  279. "{{foo|bar=baz|"
  280. "{{foo|bar|baz"
  281. "{{foo|bar|baz="
  282. "{{foo|bar|baz=biz"
  283. "{{foo|bar=baz|biz"
  284. "{{foo|bar=baz|biz="
  285. "{{foo|bar=baz|biz=buzz"