A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. name: basic
  2. label: basic external link
  3. input: "http://example.com/"
  4. output: [ExternalLinkOpen(brackets=False), Text(text="http://example.com/"), ExternalLinkClose()]
  5. ---
  6. name: basic_brackets
  7. label: basic external link in brackets
  8. input: "[http://example.com/]"
  9. output: [ExternalLinkOpen(brackets=True), Text(text="http://example.com/"), ExternalLinkClose()]
  10. ---
  11. name: brackets_space
  12. label: basic external link in brackets, with a space after
  13. input: "[http://example.com/ ]"
  14. output: [ExternalLinkOpen(brackets=True), Text(text="http://example.com/"), ExternalLinkSeparator(), ExternalLinkClose()]
  15. ---
  16. name: brackets_title
  17. label: basic external link in brackets, with a title
  18. input: "[http://example.com/ Example]"
  19. output: [ExternalLinkOpen(brackets=True), Text(text="http://example.com/"), ExternalLinkSeparator(), Text(text="Example"), ExternalLinkClose()]
  20. ---
  21. name: brackets_multiword_title
  22. label: basic external link in brackets, with a multi-word title
  23. input: "[http://example.com/ Example Web Page]"
  24. output: [ExternalLinkOpen(brackets=True), Text(text="http://example.com/"), ExternalLinkSeparator(), Text(text="Example Web Page"), ExternalLinkClose()]
  25. ---
  26. name: brackets_adjacent
  27. label: three adjacent bracket-enclosed external links
  28. input: "[http://foo.com/ Foo][http://bar.com/ Bar]\n[http://baz.com/ Baz]"
  29. output: [ExternalLinkOpen(brackets=True), Text(text="http://foo.com/"), ExternalLinkSeparator(), Text(text="Foo"), ExternalLinkClose(), ExternalLinkOpen(brackets=True), Text(text="http://bar.com/"), ExternalLinkSeparator(), Text(text="Bar"), ExternalLinkClose(), Text(text="\n"), ExternalLinkOpen(brackets=True), Text(text="http://baz.com/"), ExternalLinkSeparator(), Text(text="Baz"), ExternalLinkClose()]
  30. ---
  31. name: brackets_newline_before
  32. label: bracket-enclosed link with a newline before the title
  33. input: "[http://example.com/ \nExample]"
  34. output: [Text(text="["), ExternalLinkOpen(brackets=False), Text(text="http://example.com/"), ExternalLinkClose(), Text(text=" \nExample]")]
  35. ---
  36. name: brackets_newline_inside
  37. label: bracket-enclosed link with a newline in the title
  38. input: "[http://example.com/ Example \nWeb Page]"
  39. output: [Text(text="["), ExternalLinkOpen(brackets=False), Text(text="http://example.com/"), ExternalLinkClose(), Text(text=" Example \nWeb Page]")]
  40. ---
  41. name: brackets_newline_after
  42. label: bracket-enclosed link with a newline after the title
  43. input: "[http://example.com/ Example\n]"
  44. output: [Text(text="["), ExternalLinkOpen(brackets=False), Text(text="http://example.com/"), ExternalLinkClose(), Text(text=" Example\n]")]
  45. ---
  46. name: brackets_space_before
  47. label: bracket-enclosed link with a space before the URL
  48. input: "[ http://example.com Example]"
  49. output: [Text(text="[ "), ExternalLinkOpen(brackets=False), Text(text="http://example.com"), ExternalLinkClose(), Text(text=" Example]")]
  50. ---
  51. name: brackets_title_like_url
  52. label: bracket-enclosed link with a title that looks like a URL
  53. input: "[http://example.com http://example.com]"
  54. output: [ExternalLinkOpen(brackets=True), Text(text="http://example.com"), ExternalLinkSeparator(), Text(text="http://example.com"), ExternalLinkClose()]
  55. ---
  56. name: brackets_recursive
  57. label: bracket-enclosed link with a bracket-enclosed link as the title
  58. input: "[http://example.com [http://example.com]]"
  59. output: [ExternalLinkOpen(brackets=True), Text(text="http://example.com"), ExternalLinkSeparator(), Text(text="[http://example.com"), ExternalLinkClose(), Text(text="]")]
  60. ---
  61. name: period_after
  62. label: a period after a free link that is excluded
  63. input: "http://example.com."
  64. output: [ExternalLinkOpen(brackets=False), Text(text="http://example.com"), ExternalLinkClose(), Text(text=".")]
  65. ---
  66. name: colons_after
  67. label: colons after a free link that are excluded
  68. input: "http://example.com/foo:bar.:;baz!?,"
  69. output: [ExternalLinkOpen(brackets=False), Text(text="http://example.com/foo:bar.:;baz"), ExternalLinkClose(), Text(text="!?,")]
  70. ---
  71. name: close_paren_after_excluded
  72. label: a closing parenthesis after a free link that is excluded
  73. input: "http://example.)com)"
  74. output: [ExternalLinkOpen(brackets=False), Text(text="http://example.)com"), ExternalLinkClose(), Text(text=")")]
  75. ---
  76. name: close_paren_after_included
  77. label: a closing parenthesis after a free link that is included because of an opening parenthesis in the URL
  78. input: "http://example.(com)"
  79. output: [ExternalLinkOpen(brackets=False), Text(text="http://example.(com)"), ExternalLinkClose()]
  80. ---
  81. name: open_bracket_inside
  82. label: an open bracket inside a free link that causes it to be ended abruptly
  83. input: "http://foobar[baz.com"
  84. output: [ExternalLinkOpen(brackets=False), Text(text="http://foobar"), ExternalLinkClose(), Text(text="[baz.com")]
  85. ---
  86. name: brackets_period_after
  87. label: a period after a bracket-enclosed link that is included
  88. input: "[http://example.com. Example]"
  89. output: [ExternalLinkOpen(brackets=True), Text(text="http://example.com."), ExternalLinkSeparator(), Text(text="Example"), ExternalLinkClose()]
  90. ---
  91. name: brackets_punct_after
  92. label: punctuation after a bracket-enclosed link that are included
  93. input: "[http://example.com/foo:bar.:;baz!?, Example]"
  94. output: [ExternalLinkOpen(brackets=True), Text(text="http://example.com/foo:bar.:;baz!?,"), ExternalLinkSeparator(), Text(text="Example"), ExternalLinkClose()]
  95. ---
  96. name: brackets_close_paren_after_included
  97. label: a closing parenthesis after a bracket-enclosed link that is included
  98. input: "[http://example.)com) Example]"
  99. output: [ExternalLinkOpen(brackets=True), Text(text="http://example.)com)"), ExternalLinkSeparator(), Text(text="Example"), ExternalLinkClose()]
  100. ---
  101. name: brackets_close_paren_after_included_2
  102. label: a closing parenthesis after a bracket-enclosed link that is also included
  103. input: "[http://example.(com) Example]"
  104. output: [ExternalLinkOpen(brackets=True), Text(text="http://example.(com)"), ExternalLinkSeparator(), Text(text="Example"), ExternalLinkClose()]
  105. ---
  106. name: brackets_open_bracket_inside
  107. label: an open bracket inside a bracket-enclosed link that is also included
  108. input: "[http://foobar[baz.com Example]"
  109. output: [ExternalLinkOpen(brackets=True), Text(text="http://foobar[baz.com"), ExternalLinkSeparator(), Text(text="Example"), ExternalLinkClose()]
  110. ---
  111. name: adjacent_space
  112. label: two free links separated by a space
  113. input: "http://example.com http://example.com"
  114. output: [ExternalLinkOpen(brackets=False), Text(text="http://example.com"), ExternalLinkClose(), Text(text=" "), ExternalLinkOpen(brackets=False), Text(text="http://example.com"), ExternalLinkClose()]
  115. ---
  116. name: adjacent_newline
  117. label: two free links separated by a newline
  118. input: "http://example.com\nhttp://example.com"
  119. output: [ExternalLinkOpen(brackets=False), Text(text="http://example.com"), ExternalLinkClose(), Text(text="\n"), ExternalLinkOpen(brackets=False), Text(text="http://example.com"), ExternalLinkClose()]
  120. ---
  121. name: adjacent_close_bracket
  122. label: two free links separated by a close bracket
  123. input: "http://example.com]http://example.com"
  124. output: [ExternalLinkOpen(brackets=False), Text(text="http://example.com"), ExternalLinkClose(), Text(text="]"), ExternalLinkOpen(brackets=False), Text(text="http://example.com"), ExternalLinkClose()]
  125. ---
  126. name: html_entity_in_url
  127. label: a HTML entity parsed correctly inside a free link
  128. input: "http://exa mple.com/"
  129. output: [ExternalLinkOpen(brackets=False), Text(text="http://exa"), HTMLEntityStart(), Text(text="nbsp"), HTMLEntityEnd(), Text(text="mple.com/"), ExternalLinkClose()]
  130. ---
  131. name: template_in_url
  132. label: a template parsed correctly inside a free link
  133. input: "http://exa{{template}}mple.com/"
  134. output: [ExternalLinkOpen(brackets=False), Text(text="http://exa"), TemplateOpen(), Text(text="template"), TemplateClose(), Text(text="mple.com/"), ExternalLinkClose()]
  135. ---
  136. name: argument_in_url
  137. label: an argument parsed correctly inside a free link
  138. input: "http://exa{{{argument}}}mple.com/"
  139. output: [ExternalLinkOpen(brackets=False), Text(text="http://exa"), ArgumentOpen(), Text(text="argument"), ArgumentClose(), Text(text="mple.com/"), ExternalLinkClose()]
  140. ---
  141. name: wikilink_in_url
  142. label: a wikilink that destroys a free link
  143. input: "http://exa[[wikilink]]mple.com/"
  144. output: [ExternalLinkOpen(brackets=False), Text(text="http://exa"), ExternalLinkClose(), WikilinkOpen(), Text(text="wikilink"), WikilinkClose(), Text(text="mple.com/")]
  145. ---
  146. name: external_link_in_url
  147. label: a bracketed link that destroys a free link
  148. input: "http://exa[http://example.com/]mple.com/"
  149. output: [ExternalLinkOpen(brackets=False), Text(text="http://exa"), ExternalLinkClose(), ExternalLinkOpen(brackets=True), Text(text="http://example.com/"), ExternalLinkClose(), Text(text="mple.com/")]
  150. ---
  151. name: spaces_padding
  152. label: spaces padding a free link
  153. input: " http://example.com "
  154. output: [Text(text=" "), ExternalLinkOpen(brackets=False), Text(text="http://example.com"), ExternalLinkClose(), Text(text=" ")]
  155. ---
  156. name: text_and_spaces_padding
  157. label: text and spaces padding a free link
  158. input: "x http://example.com x"
  159. output: [Text(text="x "), ExternalLinkOpen(brackets=False), Text(text="http://example.com"), ExternalLinkClose(), Text(text=" x")]
  160. ---
  161. name: template_before
  162. label: a template before a free link
  163. input: "{{foo}}http://example.com"
  164. output: [TemplateOpen(), Text(text="foo"), TemplateClose(), ExternalLinkOpen(brackets=False), Text(text="http://example.com"), ExternalLinkClose()]
  165. ---
  166. name: spaces_padding_no_slashes
  167. label: spaces padding a free link with no slashes after the colon
  168. input: " mailto:example@example.com "
  169. output: [Text(text=" "), ExternalLinkOpen(brackets=False), Text(text="mailto:example@example.com"), ExternalLinkClose(), Text(text=" ")]
  170. ---
  171. name: text_and_spaces_padding_no_slashes
  172. label: text and spaces padding a free link with no slashes after the colon
  173. input: "x mailto:example@example.com x"
  174. output: [Text(text="x "), ExternalLinkOpen(brackets=False), Text(text="mailto:example@example.com"), ExternalLinkClose(), Text(text=" x")]
  175. ---
  176. name: template_before_no_slashes
  177. label: a template before a free link with no slashes after the colon
  178. input: "{{foo}}mailto:example@example.com"
  179. output: [TemplateOpen(), Text(text="foo"), TemplateClose(), ExternalLinkOpen(brackets=False), Text(text="mailto:example@example.com"), ExternalLinkClose()]
  180. ---
  181. name: no_slashes
  182. label: a free link with no slashes after the colon
  183. input: "mailto:example@example.com"
  184. output: [ExternalLinkOpen(brackets=False), Text(text="mailto:example@example.com"), ExternalLinkClose()]
  185. ---
  186. name: slashes_optional
  187. label: a free link using a scheme that doesn't need slashes, but has them anyway
  188. input: "mailto://example@example.com"
  189. output: [ExternalLinkOpen(brackets=False), Text(text="mailto://example@example.com"), ExternalLinkClose()]
  190. ---
  191. name: short
  192. label: a very short free link
  193. input: "mailto://abc"
  194. output: [ExternalLinkOpen(brackets=False), Text(text="mailto://abc"), ExternalLinkClose()]
  195. ---
  196. name: slashes_missing
  197. label: slashes missing from a free link with a scheme that requires them
  198. input: "http:example@example.com"
  199. output: [Text(text="http:example@example.com")]
  200. ---
  201. name: no_scheme_but_slashes
  202. label: no scheme in a free link, but slashes (protocol-relative free links are not supported)
  203. input: "//example.com"
  204. output: [Text(text="//example.com")]
  205. ---
  206. name: no_scheme_but_colon
  207. label: no scheme in a free link, but a colon
  208. input: " :example.com"
  209. output: [Text(text=" :example.com")]
  210. ---
  211. name: no_scheme_but_colon_and_slashes
  212. label: no scheme in a free link, but a colon and slashes
  213. input: " ://example.com"
  214. output: [Text(text=" ://example.com")]
  215. ---
  216. name: fake_scheme_no_slashes
  217. label: a nonexistent scheme in a free link, without slashes
  218. input: "fake:example.com"
  219. output: [Text(text="fake:example.com")]
  220. ---
  221. name: fake_scheme_slashes
  222. label: a nonexistent scheme in a free link, with slashes
  223. input: "fake://example.com"
  224. output: [Text(text="fake://example.com")]
  225. ---
  226. name: fake_scheme_brackets_no_slashes
  227. label: a nonexistent scheme in a bracketed link, without slashes
  228. input: "[fake:example.com]"
  229. output: [Text(text="[fake:example.com]")]
  230. ---
  231. name: fake_scheme_brackets_slashes
  232. label: #=a nonexistent scheme in a bracketed link, with slashes
  233. input: "[fake://example.com]"
  234. output: [Text(text="[fake://example.com]")]
  235. ---
  236. name: interrupted_scheme
  237. label: an otherwise valid scheme with something in the middle of it, in a free link
  238. input: "ht?tp://example.com"
  239. output: [Text(text="ht?tp://example.com")]
  240. ---
  241. name: interrupted_scheme_brackets
  242. label: an otherwise valid scheme with something in the middle of it, in a bracketed link
  243. input: "[ht?tp://example.com]"
  244. output: [Text(text="[ht?tp://example.com]")]
  245. ---
  246. name: no_slashes_brackets
  247. label: no slashes after the colon in a bracketed link
  248. input: "[mailto:example@example.com Example]"
  249. output: [ExternalLinkOpen(brackets=True), Text(text="mailto:example@example.com"), ExternalLinkSeparator(), Text(text="Example"), ExternalLinkClose()]
  250. ---
  251. name: space_before_no_slashes_brackets
  252. label: a space before a bracketed link with no slashes after the colon
  253. input: "[ mailto:example@example.com Example]"
  254. output: [Text(text="[ "), ExternalLinkOpen(brackets=False), Text(text="mailto:example@example.com"), ExternalLinkClose(), Text(text=" Example]")]
  255. ---
  256. name: slashes_optional_brackets
  257. label: a bracketed link using a scheme that doesn't need slashes, but has them anyway
  258. input: "[mailto://example@example.com Example]"
  259. output: [ExternalLinkOpen(brackets=True), Text(text="mailto://example@example.com"), ExternalLinkSeparator(), Text(text="Example"), ExternalLinkClose()]
  260. ---
  261. name: short_brackets
  262. label: a very short link in brackets
  263. input: "[mailto://abc Example]"
  264. output: [ExternalLinkOpen(brackets=True), Text(text="mailto://abc"), ExternalLinkSeparator(), Text(text="Example"), ExternalLinkClose()]
  265. ---
  266. name: slashes_missing_brackets
  267. label: slashes missing from a scheme that requires them in a bracketed link
  268. input: "[http:example@example.com Example]"
  269. output: [Text(text="[http:example@example.com Example]")]
  270. ---
  271. name: protcol_relative
  272. label: a protocol-relative link (in brackets)
  273. input: "[//example.com Example]"
  274. output: [ExternalLinkOpen(brackets=True), Text(text="//example.com"), ExternalLinkSeparator(), Text(text="Example"), ExternalLinkClose()]
  275. ---
  276. name: scheme_missing_but_colon_brackets
  277. label: scheme missing from a bracketed link, but with a colon
  278. input: "[:example.com Example]"
  279. output: [Text(text="[:example.com Example]")]
  280. ---
  281. name: scheme_missing_but_colon_slashes_brackets
  282. label: scheme missing from a bracketed link, but with a colon and slashes
  283. input: "[://example.com Example]"
  284. output: [Text(text="[://example.com Example]")]
  285. ---
  286. name: unclosed_protocol_relative
  287. label: an unclosed protocol-relative bracketed link
  288. input: "[//example.com"
  289. output: [Text(text="[//example.com")]
  290. ---
  291. name: space_before_protcol_relative
  292. label: a space before a protocol-relative bracketed link
  293. input: "[ //example.com]"
  294. output: [Text(text="[ //example.com]")]
  295. ---
  296. name: unclosed_just_scheme
  297. label: an unclosed bracketed link, ending after the scheme
  298. input: "[http"
  299. output: [Text(text="[http")]
  300. ---
  301. name: unclosed_scheme_colon
  302. label: an unclosed bracketed link, ending after the colon
  303. input: "[http:"
  304. output: [Text(text="[http:")]
  305. ---
  306. name: unclosed_scheme_colon_slashes
  307. label: an unclosed bracketed link, ending after the slashes
  308. input: "[http://"
  309. output: [Text(text="[http://")]
  310. ---
  311. name: incomplete_bracket
  312. label: just an open bracket
  313. input: "["
  314. output: [Text(text="[")]
  315. ---
  316. name: incomplete_scheme_colon
  317. label: a free link with just a scheme and a colon
  318. input: "http:"
  319. output: [Text(text="http:")]
  320. ---
  321. name: incomplete_scheme_colon_slashes
  322. label: a free link with just a scheme, colon, and slashes
  323. input: "http://"
  324. output: [Text(text="http://")]
  325. ---
  326. name: brackets_scheme_but_no_url
  327. label: brackets around a scheme and a colon
  328. input: "[mailto:]"
  329. output: [Text(text="[mailto:]")]
  330. ---
  331. name: brackets_scheme_slashes_but_no_url
  332. label: brackets around a scheme, colon, and slashes
  333. input: "[http://]"
  334. output: [Text(text="[http://]")]
  335. ---
  336. name: brackets_scheme_title_but_no_url
  337. label: brackets around a scheme, colon, and slashes, with a title
  338. input: "[http:// Example]"
  339. output: [Text(text="[http:// Example]")]