A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

448 строки
19 KiB

  1. Changelog
  2. =========
  3. v0.7.1
  4. ------
  5. Unreleased
  6. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.7.0...main>`__):
  7. - Modernize packaging.
  8. - Explicitly support ``$WITH_EXTENSION`` / ``$WITHOUT_EXTENSION`` to control
  9. whether the C tokenizer should be built.
  10. - Fix building in C23 (e.g. in GCC 15).
  11. (`#340 <https://github.com/earwig/mwparserfromhell/issues/340>`_)
  12. v0.7.0
  13. ------
  14. `Released June 28, 2025 <https://github.com/earwig/mwparserfromhell/tree/v0.7.0>`_
  15. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.6.6...v0.7.0>`__):
  16. - Dropped support for end-of-life Python 3.8.
  17. - Added support for Python 3.13.
  18. - Added type hints and fixed various type-checker complaints.
  19. (`#338 <https://github.com/earwig/mwparserfromhell/pull/338>`_)
  20. - Added ``after`` parameter to :meth:`.Template.add`.
  21. (`#281 <https://github.com/earwig/mwparserfromhell/issues/281>`_,
  22. `#315 <https://github.com/earwig/mwparserfromhell/pull/315>`_)
  23. - Added :meth:`.Template.update` method to set multiple parameters at once.
  24. (`#337 <https://github.com/earwig/mwparserfromhell/pull/337>`_)
  25. v0.6.6
  26. ------
  27. `Released January 4, 2024 <https://github.com/earwig/mwparserfromhell/tree/v0.6.6>`_
  28. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.6.5...v0.6.6>`__):
  29. - Dropped support for end-of-life Python 3.7.
  30. - Added support for Python 3.12.
  31. - Raised nested node depth limit from 40 to 100 to match current MediaWiki.
  32. (`#313 <https://github.com/earwig/mwparserfromhell/issues/313>`_)
  33. v0.6.5
  34. ------
  35. `Released September 5, 2023 <https://github.com/earwig/mwparserfromhell/tree/v0.6.5>`_
  36. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.6.4...v0.6.5>`__):
  37. - Dropped support for end-of-life Python 3.6.
  38. - Added support for Python 3.11.
  39. - Fixed parsing of leading zeros in named HTML entities.
  40. (`#288 <https://github.com/earwig/mwparserfromhell/issues/288>`_)
  41. - Fixed memory leak parsing tags.
  42. (`#303 <https://github.com/earwig/mwparserfromhell/issues/303>`_)
  43. - Fixed pickling SmartList objects.
  44. (`#289 <https://github.com/earwig/mwparserfromhell/issues/289>`_)
  45. v0.6.4
  46. ------
  47. `Released February 14, 2022 <https://github.com/earwig/mwparserfromhell/tree/v0.6.4>`_
  48. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.6.3...v0.6.4>`__):
  49. - Dropped support for end-of-life Python 3.5.
  50. - Added support for Python 3.10.
  51. (`#278 <https://github.com/earwig/mwparserfromhell/issues/278>`_)
  52. - Fixed a regression in v0.6.2 that broke parsing of nested wikilinks in file
  53. captions. For now, the parser will handle interpret wikilinks in normal links
  54. as well, even though this differs from MediaWiki.
  55. (`#270 <https://github.com/earwig/mwparserfromhell/issues/270>`_)
  56. v0.6.3
  57. ------
  58. `Released September 2, 2021 <https://github.com/earwig/mwparserfromhell/tree/v0.6.3>`_
  59. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.6.2...v0.6.3>`__):
  60. - Added Linux AArch64 wheels.
  61. (`#276 <https://github.com/earwig/mwparserfromhell/issues/276>`_)
  62. - Fixed C integer conversion, manifesting as parsing errors on big-endian
  63. platforms.
  64. (`#277 <https://github.com/earwig/mwparserfromhell/issues/277>`_)
  65. v0.6.2
  66. ------
  67. `Released May 16, 2021 <https://github.com/earwig/mwparserfromhell/tree/v0.6.2>`_
  68. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.6...v0.6.2>`__):
  69. - Improved parsing of external links.
  70. (`#232 <https://github.com/earwig/mwparserfromhell/issues/232>`_)
  71. - Fixed parsing of nested wikilinks.
  72. - Ported tests to pytest.
  73. (`#237 <https://github.com/earwig/mwparserfromhell/issues/237>`_)
  74. - Moved mwparserfromhell package to src/ dir.
  75. - There was no 0.6.1 release due to a packaging error.
  76. v0.6
  77. ----
  78. `Released December 21, 2020 <https://github.com/earwig/mwparserfromhell/tree/v0.6>`_
  79. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.5.4...v0.6>`__):
  80. Thanks to everyone for their patience with this release!
  81. - Breaking change: dropped support for end-of-life Python 2.7 and 3.4.
  82. - Added support for Python 3.8 and 3.9.
  83. - Added binary wheels for Linux and macOS.
  84. - Updated :meth:`.Wikicode.matches` to recognize underscores as being
  85. equivalent to spaces.
  86. (`#216 <https://github.com/earwig/mwparserfromhell/issues/216>`_)
  87. - Added a `default` parameter to :meth:`.Template.get`, and implement dict-style
  88. item access for template parameters.
  89. (`#252 <https://github.com/earwig/mwparserfromhell/issues/252>`_)
  90. - Fixed a rare parsing bug involving deeply nested style tags.
  91. (`#224 <https://github.com/earwig/mwparserfromhell/issues/224>`_)
  92. - Fixed parsing of section headings inside templates.
  93. (`#233 <https://github.com/earwig/mwparserfromhell/issues/233>`_)
  94. - Updated HTML tag definitions.
  95. - Internal refactoring and cleanup.
  96. v0.5.4
  97. ------
  98. `Released May 15, 2019 <https://github.com/earwig/mwparserfromhell/tree/v0.5.4>`_
  99. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.5.3...v0.5.4>`__):
  100. - Fixed an unlikely crash in the C tokenizer when interrupted while parsing
  101. a heading.
  102. v0.5.3
  103. ------
  104. `Released March 30, 2019 <https://github.com/earwig/mwparserfromhell/tree/v0.5.3>`_
  105. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.5.2...v0.5.3>`__):
  106. - Fixed manual construction of Node objects, previously unsupported.
  107. (`#214 <https://github.com/earwig/mwparserfromhell/issues/214>`_)
  108. - Fixed :class:`.Wikicode` transformation methods (:meth:`.Wikicode.replace`,
  109. :meth:`.Wikicode.remove`, etc.) when passed an empty section as an argument.
  110. (`#212 <https://github.com/earwig/mwparserfromhell/issues/212>`_)
  111. - Fixed the parser getting stuck inside malformed tables.
  112. (`#206 <https://github.com/earwig/mwparserfromhell/issues/206>`_)
  113. v0.5.2
  114. ------
  115. `Released November 1, 2018 <https://github.com/earwig/mwparserfromhell/tree/v0.5.2>`_
  116. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.5.1...v0.5.2>`__):
  117. - Dropped support for end-of-life Python versions 2.6, 3.2, 3.3.
  118. (`#199 <https://github.com/earwig/mwparserfromhell/issues/199>`_,
  119. `#204 <https://github.com/earwig/mwparserfromhell/pull/204>`_)
  120. - Fixed signals getting stuck inside the C tokenizer until parsing finishes,
  121. in pathological cases.
  122. (`#206 <https://github.com/earwig/mwparserfromhell/issues/206>`_)
  123. - Fixed `<wbr>` not being considered a single-only tag.
  124. (`#200 <https://github.com/earwig/mwparserfromhell/pull/200>`_)
  125. - Fixed a C tokenizer crash on Python 3.7 when compiled with assertions.
  126. (`#208 <https://github.com/earwig/mwparserfromhell/issues/208>`_)
  127. - Cleaned up some minor documentation issues.
  128. (`#207 <https://github.com/earwig/mwparserfromhell/pull/207>`_)
  129. v0.5.1
  130. ------
  131. `Released March 3, 2018 <https://github.com/earwig/mwparserfromhell/tree/v0.5.1>`_
  132. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.5...v0.5.1>`__):
  133. - Improved behavior when adding parameters to templates (via
  134. :meth:`.Template.add`) with poorly formatted whitespace conventions.
  135. (`#185 <https://github.com/earwig/mwparserfromhell/issues/185>`_)
  136. - Fixed the parser getting stuck in deeply nested HTML tags with unclosed,
  137. quoted attributes.
  138. (`#190 <https://github.com/earwig/mwparserfromhell/issues/190>`_)
  139. v0.5
  140. ----
  141. `Released June 23, 2017 <https://github.com/earwig/mwparserfromhell/tree/v0.5>`_
  142. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.4.4...v0.5>`__):
  143. - Added :meth:`.Wikicode.contains` to determine whether a :class:`.Node` or
  144. :class:`.Wikicode` object is contained within another :class:`.Wikicode`
  145. object.
  146. - Added :meth:`.Wikicode.get_ancestors` and :meth:`.Wikicode.get_parent` to
  147. find all ancestors and the direct parent of a :class:`.Node`, respectively.
  148. - Fixed a long-standing performance issue with deeply nested, invalid syntax
  149. (`issue #42 <https://github.com/earwig/mwparserfromhell/issues/42>`_). The
  150. parser should be much faster on certain complex pages. The "max cycle"
  151. restriction has also been removed, so some situations where templates at the
  152. end of a page were being skipped are now resolved.
  153. - Made :meth:`Template.remove(keep_field=True) <.Template.remove>` behave more
  154. reasonably when the parameter is already empty.
  155. - Added the *keep_template_params* argument to :meth:`.Wikicode.strip_code`.
  156. If *True*, then template parameters will be preserved in the output.
  157. - :class:`.Wikicode` objects can now be pickled properly (fixed infinite
  158. recursion error on incompletely-constructed :class:`.StringMixIn`
  159. subclasses).
  160. - Fixed :meth:`.Wikicode.matches`\ 's behavior on iterables besides lists and
  161. tuples.
  162. - Fixed ``len()`` sometimes raising ``ValueError`` on empty node lists.
  163. - Fixed a rare parsing bug involving self-closing tags inside the attributes of
  164. unpaired tags.
  165. - Fixed release script after changes to PyPI.
  166. v0.4.4
  167. ------
  168. `Released December 30, 2016 <https://github.com/earwig/mwparserfromhell/tree/v0.4.4>`_
  169. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.4.3...v0.4.4>`__):
  170. - Added support for Python 3.6.
  171. - Fixed parsing bugs involving:
  172. - wikitables nested in templates;
  173. - wikitable error recovery when unable to recurse;
  174. - templates nested in template parameters before other parameters.
  175. - Fixed parsing file-like objects.
  176. - Made builds deterministic.
  177. - Documented caveats.
  178. v0.4.3
  179. ------
  180. `Released October 29, 2015 <https://github.com/earwig/mwparserfromhell/tree/v0.4.3>`_
  181. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.4.2...v0.4.3>`__):
  182. - Added Windows binaries for Python 3.5.
  183. - Fixed edge cases involving wikilinks inside of external links and vice versa.
  184. - Fixed a C tokenizer crash when a keyboard interrupt happens while parsing.
  185. v0.4.2
  186. ------
  187. `Released July 30, 2015 <https://github.com/earwig/mwparserfromhell/tree/v0.4.2>`__
  188. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.4.1...v0.4.2>`__):
  189. - Fixed setup script not including header files in releases.
  190. - Fixed Windows binary uploads.
  191. v0.4.1
  192. ------
  193. `Released July 30, 2015 <https://github.com/earwig/mwparserfromhell/tree/v0.4.1>`__
  194. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.4...v0.4.1>`__):
  195. - The process for building Windows binaries has been fixed, and these should be
  196. distributed along with new releases. Windows users can now take advantage of
  197. C speedups without having a compiler of their own.
  198. - Added support for Python 3.5.
  199. - ``<`` and ``>`` are now disallowed in wikilink titles and template names.
  200. This includes when denoting tags, but not comments.
  201. - Fixed the behavior of *preserve_spacing* in :meth:`.Template.add` and
  202. *keep_field* in :meth:`.Template.remove` on parameters with hidden keys.
  203. - Removed :meth:`._ListProxy.detach`. :class:`.SmartList`\ s now use weak
  204. references and their children are garbage-collected properly.
  205. - Fixed parser bugs involving:
  206. - templates with completely blank names;
  207. - templates with newlines and comments.
  208. - Heavy refactoring and fixes to the C tokenizer, including:
  209. - corrected a design flaw in text handling, allowing for substantial speed
  210. improvements when parsing long strings of plain text;
  211. - implemented new Python 3.3
  212. `PEP 393 <https://www.python.org/dev/peps/pep-0393/>`_ Unicode APIs.
  213. - Fixed various bugs in :class:`.SmartList`, including one that was causing
  214. memory issues on 64-bit builds of Python 2 on Windows.
  215. - Fixed some bugs in the release scripts.
  216. v0.4
  217. ----
  218. `Released May 23, 2015 <https://github.com/earwig/mwparserfromhell/tree/v0.4>`_
  219. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.3.3...v0.4>`__):
  220. - The parser now falls back on pure Python mode if C extensions cannot be
  221. built. This fixes an issue that prevented some Windows users from installing
  222. the parser.
  223. - Added support for parsing wikicode tables (patches by David Winegar).
  224. - Added a script to test for memory leaks in :file:`scripts/memtest.py`.
  225. - Added a script to do releases in :file:`scripts/release.sh`.
  226. - *skip_style_tags* can now be passed to :func:`mwparserfromhell.parse()
  227. <.parse_anything>` (previously, only :meth:`.Parser.parse` allowed it).
  228. - The *recursive* argument to :class:`Wikicode's <.Wikicode>` :meth:`.filter`
  229. methods now accepts a third option, ``RECURSE_OTHERS``, which recurses over
  230. all children except instances of *forcetype* (for example,
  231. ``code.filter_templates(code.RECURSE_OTHERS)`` returns all un-nested
  232. templates).
  233. - The parser now understands HTML tag attributes quoted with single quotes.
  234. When setting a tag attribute's value, quotes will be added if necessary. As
  235. part of this, :class:`.Attribute`\ 's :attr:`~.Attribute.quoted` attribute
  236. has been changed to :attr:`~.Attribute.quotes`, and is now either a string or
  237. ``None``.
  238. - Calling :meth:`.Template.remove` with a :class:`.Parameter` object that is
  239. not part of the template now raises :exc:`ValueError` instead of doing
  240. nothing.
  241. - :class:`.Parameter`\ s with non-integer keys can no longer be created with
  242. *showkey=False*, nor have the value of this attribute be set to *False*
  243. later.
  244. - :meth:`._ListProxy.destroy` has been changed to :meth:`._ListProxy.detach`,
  245. and now works in a more useful way.
  246. - If something goes wrong while parsing, :exc:`.ParserError` will now be
  247. raised. Previously, the parser would produce an unclear :exc:`.BadRoute`
  248. exception or allow an incorrect node tree to be build.
  249. - Fixed parser bugs involving:
  250. - nested tags;
  251. - comments in template names;
  252. - tags inside of ``<nowiki>`` tags.
  253. - Added tests to ensure that parsed trees convert back to wikicode without
  254. unintentional modifications.
  255. - Added support for a :envvar:`NOWEB` environment variable, which disables a
  256. unit test that makes a web call.
  257. - Test coverage has been improved, and some minor related bugs have been fixed.
  258. - Updated and fixed some documentation.
  259. v0.3.3
  260. ------
  261. `Released April 22, 2014 <https://github.com/earwig/mwparserfromhell/tree/v0.3.3>`_
  262. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.3.2...v0.3.3>`__):
  263. - Added support for Python 2.6 and 3.4.
  264. - :meth:`.Template.has` is now passed *ignore_empty=False* by default
  265. instead of *True*. This fixes a bug when adding parameters to templates with
  266. empty fields, **and is a breaking change if you rely on the default
  267. behavior.**
  268. - The *matches* argument of :class:`Wikicode's <.Wikicode>` :meth:`.filter`
  269. methods now accepts a function (taking one argument, a :class:`.Node`, and
  270. returning a bool) in addition to a regex.
  271. - Re-added *flat* argument to :meth:`.Wikicode.get_sections`, fixed the order
  272. in which it returns sections, and made it faster.
  273. - :meth:`.Wikicode.matches` now accepts a tuple or list of
  274. strings/:class:`.Wikicode` objects instead of just a single string or
  275. :class:`.Wikicode`.
  276. - Given the frequency of issues with the (admittedly insufficient) tag parser,
  277. there's a temporary *skip_style_tags* argument to :meth:`~.Parser.parse` that
  278. ignores ``''`` and ``'''`` until these issues are corrected.
  279. - Fixed a parser bug involving nested wikilinks and external links.
  280. - C code cleanup and speed improvements.
  281. v0.3.2
  282. ------
  283. `Released September 1, 2013 <https://github.com/earwig/mwparserfromhell/tree/v0.3.2>`_
  284. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.3.1...v0.3.2>`__):
  285. - Added support for Python 3.2 (along with current support for 3.3 and 2.7).
  286. - Renamed :meth:`.Template.remove`\ 's first argument from *name* to *param*,
  287. which now accepts :class:`.Parameter` objects in addition to parameter name
  288. strings.
  289. v0.3.1
  290. ------
  291. `Released August 29, 2013 <https://github.com/earwig/mwparserfromhell/tree/v0.3.1>`_
  292. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.3...v0.3.1>`__):
  293. - Fixed a parser bug involving URLs nested inside other markup.
  294. - Fixed some typos.
  295. v0.3
  296. ----
  297. `Released August 24, 2013 <https://github.com/earwig/mwparserfromhell/tree/v0.3>`_
  298. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.2...v0.3>`__):
  299. - Added complete support for HTML :class:`Tags <.Tag>`, including forms like
  300. ``<ref>foo</ref>``, ``<ref name="bar"/>``, and wiki-markup tags like bold
  301. (``'''``), italics (``''``), and lists (``*``, ``#``, ``;`` and ``:``).
  302. - Added support for :class:`.ExternalLink`\ s (``http://example.com/`` and
  303. ``[http://example.com/ Example]``).
  304. - :class:`Wikicode's <.Wikicode>` :meth:`.filter` methods are now passed
  305. *recursive=True* by default instead of *False*. **This is a breaking change
  306. if you rely on any filter() methods being non-recursive by default.**
  307. - Added a :meth:`.matches` method to :class:`.Wikicode` for page/template name
  308. comparisons.
  309. - The *obj* param of :meth:`.Wikicode.insert_before`, :meth:`.insert_after`,
  310. :meth:`~.Wikicode.replace`, and :meth:`~.Wikicode.remove` now accepts
  311. :class:`.Wikicode` objects and strings representing parts of wikitext,
  312. instead of just nodes. These methods also make all possible substitutions
  313. instead of just one.
  314. - Renamed :meth:`.Template.has_param` to :meth:`~.Template.has` for consistency
  315. with :class:`.Template`\ 's other methods; :meth:`.has_param` is now an
  316. alias.
  317. - The C tokenizer extension now works on Python 3 in addition to Python 2.7.
  318. - Various bugfixes, internal changes, and cleanup.
  319. v0.2
  320. ----
  321. `Released June 20, 2013 <https://github.com/earwig/mwparserfromhell/tree/v0.2>`_
  322. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.1.1...v0.2>`__):
  323. - The parser now fully supports Python 3 in addition to Python 2.7.
  324. - Added a C tokenizer extension that is significantly faster than its Python
  325. equivalent. It is enabled by default (if available) and can be toggled by
  326. setting :attr:`mwparserfromhell.parser.use_c` to a boolean value.
  327. - Added a complete set of unit tests covering parsing and wikicode
  328. manipulation.
  329. - Renamed :meth:`.filter_links` to :meth:`.filter_wikilinks` (applies to
  330. :meth:`.ifilter` as well).
  331. - Added filter methods for :class:`Arguments <.Argument>`,
  332. :class:`Comments <.Comment>`, :class:`Headings <.Heading>`, and
  333. :class:`HTMLEntities <.HTMLEntity>`.
  334. - Added *before* param to :meth:`.Template.add`; renamed *force_nonconformity*
  335. to *preserve_spacing*.
  336. - Added *include_lead* param to :meth:`.Wikicode.get_sections`.
  337. - Removed *flat* param from :meth:`.get_sections`.
  338. - Removed *force_no_field* param from :meth:`.Template.remove`.
  339. - Added support for Travis CI.
  340. - Added note about Windows build issue in the README.
  341. - The tokenizer will limit itself to a realistic recursion depth to prevent
  342. errors and unreasonably long parse times.
  343. - Fixed how some nodes' attribute setters handle input.
  344. - Fixed multiple bugs in the tokenizer's handling of invalid markup.
  345. - Fixed bugs in the implementation of :class:`.SmartList` and
  346. :class:`.StringMixIn`.
  347. - Fixed some broken example code in the README; other copyedits.
  348. - Other bugfixes and code cleanup.
  349. v0.1.1
  350. ------
  351. `Released September 21, 2012 <https://github.com/earwig/mwparserfromhell/tree/v0.1.1>`_
  352. (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.1...v0.1.1>`__):
  353. - Added support for :class:`Comments <.Comment>` (``<!-- foo -->``) and
  354. :class:`Wikilinks <.Wikilink>` (``[[foo]]``).
  355. - Added corresponding :meth:`.ifilter_links` and :meth:`.filter_links` methods
  356. to :class:`.Wikicode`.
  357. - Fixed a bug when parsing incomplete templates.
  358. - Fixed :meth:`.strip_code` to affect the contents of headings.
  359. - Various copyedits in documentation and comments.
  360. v0.1
  361. ----
  362. `Released August 23, 2012 <https://github.com/earwig/mwparserfromhell/tree/v0.1>`_:
  363. - Initial release.