A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

110 řádky
2.8 KiB

  1. name: level_1
  2. label: a basic level-1 heading
  3. input: "= Heading ="
  4. output: [HeadingStart(level=1), Text(text=" Heading "), HeadingEnd()]
  5. ---
  6. name: level_2
  7. label: a basic level-2 heading
  8. input: "== Heading =="
  9. output: [HeadingStart(level=2), Text(text=" Heading "), HeadingEnd()]
  10. ---
  11. name: level_3
  12. label: a basic level-3 heading
  13. input: "=== Heading ==="
  14. output: [HeadingStart(level=3), Text(text=" Heading "), HeadingEnd()]
  15. ---
  16. name: level_4
  17. label: a basic level-4 heading
  18. input: "==== Heading ===="
  19. output: [HeadingStart(level=4), Text(text=" Heading "), HeadingEnd()]
  20. ---
  21. name: level_5
  22. label: a basic level-5 heading
  23. input: "===== Heading ====="
  24. output: [HeadingStart(level=5), Text(text=" Heading "), HeadingEnd()]
  25. ---
  26. name: level_6
  27. label: a basic level-6 heading
  28. input: "====== Heading ======"
  29. output: [HeadingStart(level=6), Text(text=" Heading "), HeadingEnd()]
  30. ---
  31. name: level_7
  32. label: a level-6 heading that pretends to be a level-7 heading
  33. input: "======= Heading ======="
  34. output: [HeadingStart(level=6), Text(text="= Heading ="), HeadingEnd()]
  35. ---
  36. name: level_3_2
  37. label: a level-2 heading that pretends to be a level-3 heading
  38. input: "=== Heading =="
  39. output: [HeadingStart(level=2), Text(text="= Heading "), HeadingEnd()]
  40. ---
  41. name: level_4_6
  42. label: a level-4 heading that pretends to be a level-6 heading
  43. input: "==== Heading ======"
  44. output: [HeadingStart(level=4), Text(text=" Heading =="), HeadingEnd()]
  45. ---
  46. name: newline_before
  47. label: a heading that starts after a newline
  48. input: "This is some text.\n== Foobar ==\nbaz"
  49. output: [Text(text="This is some text.\n"), HeadingStart(level=2), Text(text=" Foobar "), HeadingEnd(), Text(text="\nbaz")]
  50. ---
  51. name: text_after
  52. label: text on the same line after
  53. input: "This is some text.\n== Foobar == baz"
  54. output: [Text(text="This is some text.\n"), HeadingStart(level=2), Text(text=" Foobar "), HeadingEnd(), Text(text=" baz")]
  55. ---
  56. name: invalid_text_before
  57. label: invalid headings: text on the same line before
  58. input: "This is some text. == Foobar ==\nbaz"
  59. output: [Text(text="This is some text. == Foobar ==\nbaz")]
  60. ---
  61. name: invalid_newline_middle
  62. label: invalid headings: newline in the middle
  63. input: "This is some text.\n== Foo\nbar =="
  64. output: [Text(text="This is some text.\n== Foo\nbar ==")]
  65. ---
  66. name: invalid_newline_end
  67. label: invalid headings: newline in the middle
  68. input: "This is some text.\n=== Foo\n==="
  69. output: [Text(text="This is some text.\n=== Foo\n===")]
  70. ---
  71. name: invalid_nesting
  72. label: invalid headings: attempts at nesting
  73. input: "== Foo === Bar === Baz =="
  74. output: [HeadingStart(level=2), Text(text=" Foo === Bar === Baz "), HeadingEnd()]
  75. ---
  76. name: incomplete
  77. label: a heading that starts but doesn't finish
  78. input: "Foobar. \n== Heading "
  79. output: [Text(text="Foobar. \n== Heading ")]