A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

726 wiersze
32 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: blank_params
  37. label: template with blank parameters (mix of pipes and equal signs)
  38. input: "{{,||=|}}"
  39. output: [TemplateOpen(), Text(text=","), TemplateParamSeparator(), TemplateParamSeparator(), TemplateParamEquals(), TemplateParamSeparator(), TemplateClose()]
  40. ---
  41. name: nested_unnamed_param
  42. label: nested template as an unnamed parameter
  43. input: "{{foo|{{bar}}}}"
  44. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateClose()]
  45. ---
  46. name: nested_named_param_value
  47. label: nested template as a parameter value with a named parameter
  48. input: "{{foo|bar={{baz}}}}"
  49. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar"), TemplateParamEquals(), TemplateOpen(), Text(text="baz"), TemplateClose(), TemplateClose()]
  50. ---
  51. name: nested_named_param_name_and_value
  52. label: nested templates as a parameter name and value
  53. input: "{{foo|{{bar}}={{baz}}}}"
  54. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateParamEquals(), TemplateOpen(), Text(text="baz"), TemplateClose(), TemplateClose()]
  55. ---
  56. name: nested_name_start
  57. label: nested template at the beginning of a template name
  58. input: "{{{{foo}}bar}}"
  59. output: [TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), Text(text="bar"), TemplateClose()]
  60. ---
  61. name: nested_name_start_unnamed_param
  62. label: nested template at the beginning of a template name and as an unnamed parameter
  63. input: "{{{{foo}}bar|{{baz}}}}"
  64. output: [TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), Text(text="bar"), TemplateParamSeparator(), TemplateOpen(), Text(text="baz"), TemplateClose(), TemplateClose()]
  65. ---
  66. name: nested_name_start_named_param_value
  67. label: nested template at the beginning of a template name and as a parameter value with a named parameter
  68. input: "{{{{foo}}bar|baz={{biz}}}}"
  69. output: [TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), Text(text="bar"), TemplateParamSeparator(), Text(text="baz"), TemplateParamEquals(), TemplateOpen(), Text(text="biz"), TemplateClose(), TemplateClose()]
  70. ---
  71. name: nested_name_start_named_param_name_and_value
  72. label: nested template at the beginning of a template name and as a parameter name and value
  73. input: "{{{{foo}}bar|{{baz}}={{biz}}}}"
  74. output: [TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), Text(text="bar"), TemplateParamSeparator(), TemplateOpen(), Text(text="baz"), TemplateClose(), TemplateParamEquals(), TemplateOpen(), Text(text="biz"), TemplateClose(), TemplateClose()]
  75. ---
  76. name: nested_name_end
  77. label: nested template at the end of a template name
  78. input: "{{foo{{bar}}}}"
  79. output: [TemplateOpen(), Text(text="foo"), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateClose()]
  80. ---
  81. name: nested_name_end_unnamed_param
  82. label: nested template at the end of a template name and as an unnamed parameter
  83. input: "{{foo{{bar}}|{{baz}}}}"
  84. output: [TemplateOpen(), Text(text="foo"), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateParamSeparator(), TemplateOpen(), Text(text="baz"), TemplateClose(), TemplateClose()]
  85. ---
  86. name: nested_name_end_named_param_value
  87. label: nested template at the end of a template name and as a parameter value with a named parameter
  88. input: "{{foo{{bar}}|baz={{biz}}}}"
  89. output: [TemplateOpen(), Text(text="foo"), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateParamSeparator(), Text(text="baz"), TemplateParamEquals(), TemplateOpen(), Text(text="biz"), TemplateClose(), TemplateClose()]
  90. ---
  91. name: nested_name_end_named_param_name_and_value
  92. label: nested template at the end of a template name and as a parameter name and value
  93. input: "{{foo{{bar}}|{{baz}}={{biz}}}}"
  94. output: [TemplateOpen(), Text(text="foo"), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateParamSeparator(), TemplateOpen(), Text(text="baz"), TemplateClose(), TemplateParamEquals(), TemplateOpen(), Text(text="biz"), TemplateClose(), TemplateClose()]
  95. ---
  96. name: nested_name_mid
  97. label: nested template in the middle of a template name
  98. input: "{{foo{{bar}}baz}}"
  99. output: [TemplateOpen(), Text(text="foo"), TemplateOpen(), Text(text="bar"), TemplateClose(), Text(text="baz"), TemplateClose()]
  100. ---
  101. name: nested_name_mid_unnamed_param
  102. label: nested template in the middle of a template name and as an unnamed parameter
  103. input: "{{foo{{bar}}baz|{{biz}}}}"
  104. output: [TemplateOpen(), Text(text="foo"), TemplateOpen(), Text(text="bar"), TemplateClose(), Text(text="baz"), TemplateParamSeparator(), TemplateOpen(), Text(text="biz"), TemplateClose(), TemplateClose()]
  105. ---
  106. name: nested_name_mid_named_param_value
  107. label: nested template in the middle of a template name and as a parameter value with a named parameter
  108. input: "{{foo{{bar}}baz|biz={{buzz}}}}"
  109. output: [TemplateOpen(), Text(text="foo"), TemplateOpen(), Text(text="bar"), TemplateClose(), Text(text="baz"), TemplateParamSeparator(), Text(text="biz"), TemplateParamEquals(), TemplateOpen(), Text(text="buzz"), TemplateClose(), TemplateClose()]
  110. ---
  111. name: nested_name_mid_named_param_name_and_value
  112. label: nested template in the middle of a template name and as a parameter name and value
  113. input: "{{foo{{bar}}baz|{{biz}}={{buzz}}}}"
  114. 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()]
  115. ---
  116. name: nested_name_start_end
  117. label: nested template at the beginning and end of a template name
  118. input: "{{{{foo}}{{bar}}}}"
  119. output: [TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateClose()]
  120. ---
  121. name: nested_name_start_end_unnamed_param
  122. label: nested template at the beginning and end of a template name and as an unnamed parameter
  123. input: "{{{{foo}}{{bar}}|{{baz}}}}"
  124. output: [TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateParamSeparator(), TemplateOpen(), Text(text="baz"), TemplateClose(), TemplateClose()]
  125. ---
  126. name: nested_name_start_end_named_param_value
  127. label: nested template at the beginning and end of a template name and as a parameter value with a named parameter
  128. input: "{{{{foo}}{{bar}}|baz={{biz}}}}"
  129. output: [TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), TemplateOpen(), Text(text="bar"), TemplateClose(), TemplateParamSeparator(), Text(text="baz"), TemplateParamEquals(), TemplateOpen(), Text(text="biz"), TemplateClose(), TemplateClose()]
  130. ---
  131. name: nested_name_start_end_named_param_name_and_value
  132. label: nested template at the beginning and end of a template name and as a parameter name and value
  133. input: "{{{{foo}}{{bar}}|{{baz}}={{biz}}}}"
  134. 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()]
  135. ---
  136. name: nested_names_multiple
  137. label: multiple nested templates within nested templates
  138. input: "{{{{{{{{foo}}bar}}baz}}biz}}"
  139. output: [TemplateOpen(), TemplateOpen(), TemplateOpen(), TemplateOpen(), Text(text="foo"), TemplateClose(), Text(text="bar"), TemplateClose(), Text(text="baz"), TemplateClose(), Text(text="biz"), TemplateClose()]
  140. ---
  141. name: nested_names_multiple_unnamed_param
  142. label: multiple nested templates within nested templates with a nested unnamed parameter
  143. input: "{{{{{{{{foo}}bar}}baz}}biz|{{buzz}}}}"
  144. 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()]
  145. ---
  146. name: nested_names_multiple_named_param_value
  147. label: multiple nested templates within nested templates with a nested parameter value in a named parameter
  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(), Text(text="buzz"), TemplateParamEquals(), TemplateOpen(), Text(text="bin"), TemplateClose(), TemplateClose()]
  150. ---
  151. name: nested_names_multiple_named_param_name_and_value
  152. label: multiple nested templates within nested templates with a nested parameter name and value
  153. input: "{{{{{{{{foo}}bar}}baz}}biz|{{buzz}}={{bin}}}}"
  154. 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()]
  155. ---
  156. name: mixed_nested_templates
  157. label: mixed assortment of nested templates within template names, parameter names, and values
  158. input: "{{{{{{{{foo}}bar|baz=biz}}buzz}}usr|{{bin}}}}"
  159. 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()]
  160. ---
  161. name: nested_two_args
  162. label: template whose first parameter is unnamed with two templates, followed by a named parameter
  163. input: "{{a|{{b}}{{c}}|d=e}}"
  164. output: [TemplateOpen(), Text(text="a"), TemplateParamSeparator(), TemplateOpen(), Text(text="b"), TemplateClose(), TemplateOpen(), Text(text="c"), TemplateClose(), TemplateParamSeparator(), Text(text="d"), TemplateParamEquals(), Text(text="e"), TemplateClose()]
  165. ---
  166. name: newlines_start
  167. label: a newline at the start of a template name
  168. input: "{{\nfoobar}}"
  169. output: [TemplateOpen(), Text(text="\nfoobar"), TemplateClose()]
  170. ---
  171. name: newlines_end
  172. label: a newline at the end of a template name
  173. input: "{{foobar\n}}"
  174. output: [TemplateOpen(), Text(text="foobar\n"), TemplateClose()]
  175. ---
  176. name: newlines_start_end
  177. label: a newline at the start and end of a template name
  178. input: "{{\nfoobar\n}}"
  179. output: [TemplateOpen(), Text(text="\nfoobar\n"), TemplateClose()]
  180. ---
  181. name: newlines_mid
  182. label: a newline at the middle of a template name
  183. input: "{{foo\nbar}}"
  184. output: [Text(text="{{foo\nbar}}")]
  185. ---
  186. name: newlines_start_mid
  187. label: a newline at the start and middle of a template name
  188. input: "{{\nfoo\nbar}}"
  189. output: [Text(text="{{\nfoo\nbar}}")]
  190. ---
  191. name: newlines_mid_end
  192. label: a newline at the middle and end of a template name
  193. input: "{{foo\nbar\n}}"
  194. output: [Text(text="{{foo\nbar\n}}")]
  195. ---
  196. name: newlines_start_mid_end
  197. label: a newline at the start, middle, and end of a template name
  198. input: "{{\nfoo\nbar\n}}"
  199. output: [Text(text="{{\nfoo\nbar\n}}")]
  200. ---
  201. name: newlines_unnamed_param
  202. label: newlines within an unnamed template parameter
  203. input: "{{foo|\nb\nar\n}}"
  204. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="\nb\nar\n"), TemplateClose()]
  205. ---
  206. name: newlines_enclose_template_name_unnamed_param
  207. label: newlines enclosing a template name and within an unnamed template parameter
  208. input: "{{\nfoo\n|\nb\nar\n}}"
  209. output: [TemplateOpen(), Text(text="\nfoo\n"), TemplateParamSeparator(), Text(text="\nb\nar\n"), TemplateClose()]
  210. ---
  211. name: newlines_within_template_name_unnamed_param
  212. label: newlines within a template name and within an unnamed template parameter
  213. input: "{{\nfo\no\n|\nb\nar\n}}"
  214. output: [Text(text="{{\nfo\no\n|\nb\nar\n}}")]
  215. ---
  216. name: newlines_enclose_template_name_named_param_value
  217. label: newlines enclosing a template name and within a named parameter value
  218. input: "{{\nfoo\n|1=\nb\nar\n}}"
  219. output: [TemplateOpen(), Text(text="\nfoo\n"), TemplateParamSeparator(), Text(text="1"), TemplateParamEquals(), Text(text="\nb\nar\n"), TemplateClose()]
  220. ---
  221. name: newlines_within_template_name_named_param_value
  222. label: newlines within a template name and within a named parameter value
  223. input: "{{\nf\noo\n|1=\nb\nar\n}}"
  224. output: [Text(text="{{\nf\noo\n|1=\nb\nar\n}}")]
  225. ---
  226. name: newlines_named_param_name
  227. label: newlines within a parameter name
  228. input: "{{foo|\nb\nar\n=baz}}"
  229. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="\nb\nar\n"), TemplateParamEquals(), Text(text="baz"), TemplateClose()]
  230. ---
  231. name: newlines_named_param_name_param_value
  232. label: newlines within a parameter name and within a parameter value
  233. input: "{{foo|\nb\nar\n=\nba\nz\n}}"
  234. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="\nb\nar\n"), TemplateParamEquals(), Text(text="\nba\nz\n"), TemplateClose()]
  235. ---
  236. name: newlines_enclose_template_name_named_param_name
  237. label: newlines enclosing a template name and within a parameter name
  238. input: "{{\nfoo\n|\nb\nar\n=baz}}"
  239. output: [TemplateOpen(), Text(text="\nfoo\n"), TemplateParamSeparator(), Text(text="\nb\nar\n"), TemplateParamEquals(), Text(text="baz"), TemplateClose()]
  240. ---
  241. name: newlines_enclose_template_name_named_param_name_param_value
  242. label: newlines enclosing a template name and within a parameter name and within a parameter value
  243. input: "{{\nfoo\n|\nb\nar\n=\nba\nz\n}}"
  244. output: [TemplateOpen(), Text(text="\nfoo\n"), TemplateParamSeparator(), Text(text="\nb\nar\n"), TemplateParamEquals(), Text(text="\nba\nz\n"), TemplateClose()]
  245. ---
  246. name: newlines_within_template_name_named_param_name
  247. label: newlines within a template name and within a parameter name
  248. input: "{{\nfo\no\n|\nb\nar\n=baz}}"
  249. output: [Text(text="{{\nfo\no\n|\nb\nar\n=baz}}")]
  250. ---
  251. name: newlines_within_template_name_named_param_name_param_value
  252. label: newlines within a template name and within a parameter name and within a parameter value
  253. input: "{{\nf\noo\n|\nb\nar\n=\nba\nz\n}}"
  254. output: [Text(text="{{\nf\noo\n|\nb\nar\n=\nba\nz\n}}")]
  255. ---
  256. name: newlines_wildcard
  257. label: a random, complex assortment of templates and newlines
  258. input: "{{\nfoo\n|\nb\nar\n=\nb\naz\n|\nb\nuz\n}}"
  259. output: [TemplateOpen(), Text(text="\nfoo\n"), TemplateParamSeparator(), Text(text="\nb\nar\n"), TemplateParamEquals(), Text(text="\nb\naz\n"), TemplateParamSeparator(), Text(text="\nb\nuz\n"), TemplateClose()]
  260. ---
  261. name: newlines_wildcard_redux
  262. label: an even more random and complex assortment of templates and newlines
  263. input: "{{\nfoo\n|\n{{\nbar\n|\nb\naz\n=\nb\niz\n}}\n=\nb\nuzz\n}}"
  264. output: [TemplateOpen(), Text(text="\nfoo\n"), TemplateParamSeparator(), Text(text="\n"), TemplateOpen(), Text(text="\nbar\n"), TemplateParamSeparator(), Text(text="\nb\naz\n"), TemplateParamEquals(), Text(text="\nb\niz\n"), TemplateClose(), Text(text="\n"), TemplateParamEquals(), Text(text="\nb\nuzz\n"), TemplateClose()]
  265. ---
  266. name: newlines_wildcard_redux_invalid
  267. label: a variation of the newlines_wildcard_redux test that is invalid
  268. input: "{{\nfoo\n|\n{{\nb\nar\n|\nb\naz\n=\nb\niz\n}}\n=\nb\nuzz\n}}"
  269. output: [TemplateOpen(), Text(text="\nfoo\n"), TemplateParamSeparator(), Text(text="\n{{\nb\nar\n"), TemplateParamSeparator(), Text(text="\nb\naz\n"), TemplateParamEquals(), Text(text="\nb\niz\n"), TemplateClose(), Text(text="\n=\nb\nuzz\n}}")]
  270. ---
  271. name: newlines_spaces
  272. label: newlines in the middle of a template name, followed by spaces
  273. input: "{{foo\n }}"
  274. output: [TemplateOpen(), Text(text="foo\n "), TemplateClose()]
  275. ---
  276. name: newlines_spaces_param
  277. label: newlines in the middle of a template name, followed by spaces, with a parameter
  278. input: "{{foo\n |bar=baz}}"
  279. output: [TemplateOpen(), Text(text="foo\n "), TemplateParamSeparator(), Text(text="bar"), TemplateParamEquals(), Text(text="baz"), TemplateClose()]
  280. ---
  281. name: invalid_blank
  282. label: invalid template with no content
  283. input: "{{}}"
  284. output: [Text(text="{{}}")]
  285. ---
  286. name: invalid_blank_whitespace
  287. label: invalid template with no content, but whitespace
  288. input: "{{ }}"
  289. output: [Text(text="{{ }}")]
  290. ---
  291. name: invalid_blank_pipe
  292. label: invalid template with no content, but a parameter
  293. input: "{{|foo}}"
  294. output: [Text(text="{{|foo}}")]
  295. ---
  296. name: invalid_blank_whitespace_pipe
  297. label: invalid template with no content, but whitespace and a parameter
  298. input: "{{ |foo}}"
  299. output: [Text(text="{{ |foo}}")]
  300. ---
  301. name: invalid_name_left_brace_middle
  302. label: invalid characters in template name: left brace in middle
  303. input: "{{foo{bar}}"
  304. output: [Text(text="{{foo{bar}}")]
  305. ---
  306. name: invalid_name_right_brace_middle
  307. label: invalid characters in template name: right brace in middle
  308. input: "{{foo}bar}}"
  309. output: [Text(text="{{foo}bar}}")]
  310. ---
  311. name: invalid_name_left_braces
  312. label: invalid characters in template name: two left braces in middle
  313. input: "{{foo{b{ar}}"
  314. output: [Text(text="{{foo{b{ar}}")]
  315. ---
  316. name: invalid_name_left_bracket_middle
  317. label: invalid characters in template name: left bracket in middle
  318. input: "{{foo[bar}}"
  319. output: [Text(text="{{foo[bar}}")]
  320. ---
  321. name: invalid_name_right_bracket_middle
  322. label: invalid characters in template name: right bracket in middle
  323. input: "{{foo]bar}}"
  324. output: [Text(text="{{foo]bar}}")]
  325. ---
  326. name: invalid_name_left_bracket_start
  327. label: invalid characters in template name: left bracket at start
  328. input: "{{[foobar}}"
  329. output: [Text(text="{{[foobar}}")]
  330. ---
  331. name: invalid_name_right_bracket_start
  332. label: invalid characters in template name: right bracket at end
  333. input: "{{foobar]}}"
  334. output: [Text(text="{{foobar]}}")]
  335. ---
  336. name: valid_name_left_brace_start
  337. label: valid characters in template name: left brace at start
  338. input: "{{{foobar}}"
  339. output: [Text(text="{"), TemplateOpen(), Text(text="foobar"), TemplateClose()]
  340. ---
  341. name: valid_unnamed_param_left_brace
  342. label: valid characters in unnamed template parameter: left brace
  343. input: "{{foo|ba{r}}"
  344. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="ba{r"), TemplateClose()]
  345. ---
  346. name: valid_unnamed_param_braces
  347. label: valid characters in unnamed template parameter: left and right braces
  348. input: "{{foo|ba{r}}}"
  349. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="ba{r"), TemplateClose(), Text(text="}")]
  350. ---
  351. name: valid_param_name_braces
  352. label: valid characters in template parameter name: left and right braces
  353. input: "{{foo|ba{r}=baz}}"
  354. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="ba{r}"), TemplateParamEquals(), Text(text="baz"), TemplateClose()]
  355. ---
  356. name: valid_param_name_brackets
  357. label: valid characters in unnamed template parameter: left and right brackets
  358. input: "{{foo|ba[r]=baz}}"
  359. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="ba[r]"), TemplateParamEquals(), Text(text="baz"), TemplateClose()]
  360. ---
  361. name: valid_param_name_double_left_brackets
  362. label: valid characters in unnamed template parameter: double left brackets
  363. input: "{{foo|bar[[in\nvalid=baz}}"
  364. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar[[in\nvalid"), TemplateParamEquals(), Text(text="baz"), TemplateClose()]
  365. ---
  366. name: valid_param_name_double_right_brackets
  367. label: valid characters in unnamed template parameter: double right brackets
  368. input: "{{foo|bar]]=baz}}"
  369. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar]]"), TemplateParamEquals(), Text(text="baz"), TemplateClose()]
  370. ---
  371. name: valid_param_name_double_brackets
  372. label: valid characters in unnamed template parameter: double left and right brackets
  373. input: "{{foo|bar[[in\nvalid]]=baz}}"
  374. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar[[in\nvalid]]"), TemplateParamEquals(), Text(text="baz"), TemplateClose()]
  375. ---
  376. name: invalid_param_name_double_left_braces
  377. label: invalid characters in template parameter name: double left braces
  378. input: "{{foo|bar{{in\nvalid=baz}}"
  379. output: [Text(text="{{foo|bar{{in\nvalid=baz}}")]
  380. ---
  381. name: invalid_param_name_double_braces
  382. label: invalid characters in template parameter name: double left and right braces
  383. input: "{{foo|bar{{in\nvalid}}=baz}}"
  384. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar{{in\nvalid"), TemplateClose(), Text(text="=baz}}")]
  385. ---
  386. name: invalid_left_angle_bracket
  387. label: invalid template: left angle bracket in name
  388. input: "{{foo<bar}}"
  389. output: [Text(text="{{foo<bar}}")]
  390. ---
  391. name: invalid_right_angle_bracket
  392. label: invalid template: right angle bracket in name
  393. input: "{{foo>bar}}"
  394. output: [Text(text="{{foo>bar}}")]
  395. ---
  396. name: incomplete_stub
  397. label: incomplete templates that should fail gracefully: just an opening
  398. input: "{{"
  399. output: [Text(text="{{")]
  400. ---
  401. name: incomplete_plain
  402. label: incomplete templates that should fail gracefully: no close whatsoever
  403. input: "{{stuff}} {{foobar"
  404. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foobar")]
  405. ---
  406. name: incomplete_right_brace
  407. label: incomplete templates that should fail gracefully: only one right brace
  408. input: "{{stuff}} {{foobar}"
  409. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foobar}")]
  410. ---
  411. name: incomplete_pipe
  412. label: incomplete templates that should fail gracefully: a pipe
  413. input: "{{stuff}} {{foobar|"
  414. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foobar|")]
  415. ---
  416. name: incomplete_unnamed_param
  417. label: incomplete templates that should fail gracefully: an unnamed parameter
  418. input: "{{stuff}} {{foo|bar"
  419. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foo|bar")]
  420. ---
  421. name: incomplete_unnamed_param_pipe
  422. label: incomplete templates that should fail gracefully: an unnamed parameter, then a pipe
  423. input: "{{stuff}} {{foo|bar|"
  424. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foo|bar|")]
  425. ---
  426. name: incomplete_valueless_param
  427. label: incomplete templates that should fail gracefully: an a named parameter with no value
  428. input: "{{stuff}} {{foo|bar="
  429. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foo|bar=")]
  430. ---
  431. name: incomplete_valueless_param_pipe
  432. label: incomplete templates that should fail gracefully: a named parameter with no value, then a pipe
  433. input: "{{stuff}} {{foo|bar=|"
  434. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foo|bar=|")]
  435. ---
  436. name: incomplete_named_param
  437. label: incomplete templates that should fail gracefully: a named parameter with a value
  438. input: "{{stuff}} {{foo|bar=baz"
  439. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foo|bar=baz")]
  440. ---
  441. name: incomplete_named_param_pipe
  442. label: incomplete templates that should fail gracefully: a named parameter with a value, then a paipe
  443. input: "{{stuff}} {{foo|bar=baz|"
  444. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foo|bar=baz|")]
  445. ---
  446. name: incomplete_two_unnamed_params
  447. label: incomplete templates that should fail gracefully: two unnamed parameters
  448. input: "{{stuff}} {{foo|bar|baz"
  449. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foo|bar|baz")]
  450. ---
  451. name: incomplete_unnamed_param_valueless_param
  452. label: incomplete templates that should fail gracefully: an unnamed parameter, then a named parameter with no value
  453. input: "{{stuff}} {{foo|bar|baz="
  454. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foo|bar|baz=")]
  455. ---
  456. name: incomplete_unnamed_param_named_param
  457. label: incomplete templates that should fail gracefully: an unnamed parameter, then a named parameter with a value
  458. input: "{{stuff}} {{foo|bar|baz=biz"
  459. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foo|bar|baz=biz")]
  460. ---
  461. name: incomplete_named_param_unnamed_param
  462. label: incomplete templates that should fail gracefully: a named parameter with a value, then an unnamed parameter
  463. input: "{{stuff}} {{foo|bar=baz|biz"
  464. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foo|bar=baz|biz")]
  465. ---
  466. name: incomplete_named_param_valueless_param
  467. label: incomplete templates that should fail gracefully: a named parameter with a value, then a named parameter with no value
  468. input: "{{stuff}} {{foo|bar=baz|biz="
  469. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foo|bar=baz|biz=")]
  470. ---
  471. name: incomplete_two_named_params
  472. label: incomplete templates that should fail gracefully: two named parameters with values
  473. input: "{{stuff}} {{foo|bar=baz|biz=buzz"
  474. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foo|bar=baz|biz=buzz")]
  475. ---
  476. name: incomplete_nested_template_as_unnamed_param
  477. label: incomplete templates that should fail gracefully: a valid nested template as an unnamed parameter
  478. input: "{{stuff}} {{foo|{{bar}}"
  479. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foo|"), TemplateOpen(), Text(text="bar"), TemplateClose()]
  480. ---
  481. name: incomplete_nested_template_as_param_value
  482. label: incomplete templates that should fail gracefully: a valid nested template as a parameter value
  483. input: "{{stuff}} {{foo|bar={{baz}}"
  484. output: [TemplateOpen(), Text(text="stuff"), TemplateClose(), Text(text=" {{foo|bar="), TemplateOpen(), Text(text="baz"), TemplateClose()]
  485. ---
  486. name: recursion_five_hundred_opens
  487. label: test potentially dangerous recursion: five hundred template openings, without spaces
  488. input: "{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{"
  489. output: [Text(text="{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{")]
  490. ---
  491. name: recursion_one_hundred_opens
  492. label: test potentially dangerous recursion: one hundred template openings, with spaces
  493. input: "{{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{"
  494. output: [Text(text="{{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{ {{")]
  495. ---
  496. name: recursion_opens_and_closes
  497. label: test potentially dangerous recursion: template openings and closings
  498. input: "{{x|{{x}}{{x|{{x}}{{x|{{x}}{{x|{{x}}{{x|{{x}}{{x|{{x}}{{x|{{x}}{{x|{{x}}{{x|{{x}}{{x|{{x}}{{x|{{x}}{{x|{{x}}{{x|{{x}}{{x|{{x}}"
  499. output: [Text(text="{{x|"), TemplateOpen(), Text(text="x"), TemplateClose(), Text(text="{{x|"), TemplateOpen(), Text(text="x"), TemplateClose(), Text(text="{{x|"), TemplateOpen(), Text(text="x"), TemplateClose(), Text(text="{{x|"), TemplateOpen(), Text(text="x"), TemplateClose(), Text(text="{{x|"), TemplateOpen(), Text(text="x"), TemplateClose(), Text(text="{{x|"), TemplateOpen(), Text(text="x"), TemplateClose(), Text(text="{{x|"), TemplateOpen(), Text(text="x"), TemplateClose(), Text(text="{{x|"), TemplateOpen(), Text(text="x"), TemplateClose(), Text(text="{{x|"), TemplateOpen(), Text(text="x"), TemplateClose(), Text(text="{{x|"), TemplateOpen(), Text(text="x"), TemplateClose(), Text(text="{{x|"), TemplateOpen(), Text(text="x"), TemplateClose(), Text(text="{{x|"), TemplateOpen(), Text(text="x"), TemplateClose(), Text(text="{{x|"), TemplateOpen(), Text(text="x"), TemplateClose(), Text(text="{{x|"), TemplateOpen(), Text(text="x"), TemplateClose()]
  500. ---
  501. name: invalid_section_level_1
  502. label: level 1 headings inside a template are always invalid
  503. input: "{{foo|bar\n=baz=\n}}"
  504. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar\n"), TemplateParamEquals(), Text(text="baz=\n"), TemplateClose()]
  505. ---
  506. name: section_level_2
  507. label: valid level 2 heading inside a template
  508. input: "{{foo|bar\n==baz==\n}}"
  509. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar\n"), HeadingStart(level=2), Text(text="baz"), HeadingEnd(), Text(text="\n"), TemplateClose()]
  510. ---
  511. name: invalid_section_level_2
  512. label: invalid level 2 heading inside a template
  513. input: "{{foo|bar==baz==\n}}"
  514. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar"), TemplateParamEquals(), Text(text="=baz==\n"), TemplateClose()]
  515. ---
  516. name: section_level_2_after_template_parameter
  517. label: level 2 heading inside a template after a parameter
  518. input: "{{foo|bar=\n==baz==\n}}"
  519. output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar"), TemplateParamEquals(), Text(text="\n==baz==\n"), TemplateClose()]