Repository navigation
CHANGELOG.md
Latest commit
ย
History
History
View commit history for this file.
CHANGELOG.md
File metadata and controls
486 lines (336 loc) ยท 32.5 KB
Raw
Change Log
4.3.0 - 2026-11-10
This release fixes two quadratic-time parsing paths that let crafted input stall rendering for minutes (security),
aligns several parsing rules with CommonMark 0.31.2 and markdown-it 15.0.x,
turns parser rules that never advance into a RuntimeError instead of an infinite loop,
makes rendering linear on PyPy and free-threaded CPython, and adds support for Python 3.14.
Python 3.10 is still supported.
If you write plugins or render rules, or edit SyntaxTreeNode trees, please read the upgrade notes at the end.
๐ Security
- ๐ Fix quadratic-time inline parsing of long runs of characters that start an inline rule without completing one (such as
&, <, ~ or incomplete entities), which let a few hundred kilobytes of input stall rendering for seconds to minutes, in #423 , thanks to @hdimer (#411 )
- ๐ Reject unterminated inline HTML (
<!--, <?, <![CDATA[, <!X) in constant time when html is enabled (as in the default commonmark preset), instead of rescanning to the end of the input for every opener, in #428
โจ New
- โจ Add
--enable-tables to the CLI for file, standard input and interactive parsing in #425 , thanks to @user01010111 (#422 ); requested by @hartwork in #352
- โฌ๏ธ Add support for Python 3.14 in #462
๐ Improved
- ๐ Raise
RuntimeError instead of looping forever when a block or inline rule reports a match without advancing (or moves backwards), or when no block rule matches a line, as markdown-it does, in #444 , thanks to @rupayon123 , @hukkin (#336 ) and @inchang-ing (#443 ); requested by @acaprino in #441
- ๐ Fix quadratic-time HTML rendering on PyPy, GraalPy and free-threaded CPython by joining the rendered fragments once, in #458 , thanks to @DicksonWu654
- ๐ Make
StateBase.src a plain attribute, for about 4-11% faster parsing on CPython, in #450 , thanks to @deadstrobe5
- ๐ Build block line markers with one scan per line instead of one step per character in #449 , thanks to @John-Cusack
- ๐ Name the Windows end-of-input keys (Ctrl-Z then Enter) in the CLI's interactive prompt and
-h text in #463
๐ Fixed
- ๐ Fix HTML blocks of types 1-5 (comments, processing instructions, declarations, CDATA,
script/pre/style/textarea) ending at a blank line inside a list item or blockquote, porting markdown-it 14.2.0, in #406 , thanks to @binggao1230 ; reported by @Jayman2000 in #377
- ๐ Fix HTML block starts per CommonMark 0.31.2: lowercase declarations such as
<!doctype html> start a block and interrupt a paragraph, and tag names match case-insensitively in ASCII only, in #440 , thanks to @rupayon123 ; reported by @p5ych0 in #437
- ๐ Fix code spans rendered as literal backticks after an unclosed link or image label, and count only U+0020 spaces (not tabs or no-break spaces) when deciding whether to strip a code span's padding, porting markdown-it 15.0.1, in #439 , thanks to @SparkUiX ; reported by @felzab in #438
- ๐ Trim and split with the CommonMark whitespace set instead of Python's, so U+001C-U+001F and U+0085 are no longer dropped from paragraphs, headings, table cells and fence info strings, and distinct reference labels no longer match each other, in #433 , thanks to @Nexory (#418 )
- ๐ Preserve IPv6 host brackets (e.g.
http://[::1]:8000/) in normalized link and image URLs, porting markdown-it 15.0.1, in #459 , thanks to @Jinyong-Li
- ๐ Fix task-list detection consuming a literal
[ ]/[x] at the start of an indented code block in a list item in #451 , thanks to @AryanRG
- ๐ Fix an
IndexError in the html_block and heading rules at the end of the input (a table in a blockquote that ends on >) in #416 , thanks to @saket3395 ; reported by @WilcoPancras in #415
- ๐ Keep backslash escapes and entities in image alt text (
 gives alt="a * b"), porting markdown-it 15.0.0, in #446 , thanks to @gyanu2507 ; reported by @kdeldycke in #445
- ๐ Keep code span text in image alt text, porting markdown-it 15.0.0, in #460 , thanks to @jayhemnani9910
- ๐ Keep hard breaks and inline HTML in image alt text in #409 , thanks to @chuenchen309
- ๐ Keep edits to the children of inline and image nodes in
SyntaxTreeNode.to_tokens() in #453 , thanks to @KennyMcSimpson ; edited tokens are copied, so the token stream the tree was built from is left unchanged (#464 )
- ๐ Fix rule chains staying stale after
Ruler.enable, disable or enableOnly raised on an unknown rule name in #457 , thanks to @IlyaKhalafi ; reported in #456
- ๐ Fix
MarkdownIt.enable() and disable() applying a generator of rule names only to the core chain in #447 , thanks to @muneikh
- ๐ Fix the CLI's interactive mode joining input lines with an extra newline, which split every line into its own paragraph and broke hard line breaks, in #425 ; reported by @jamesquilty in #172
- ๐ CLI helpers create a default parser only when none is given in #455 , thanks to @Quinnod345
๐ Documentation
- ๐ Add a "Third-party renderers" section (mdformat, mdit_plain, MyST-Parser) and document
RendererProtocol for writing your own renderer, in #463
- ๐ Document that
MarkdownIt passes itself to renderer_cls, unlike markdown-it's renderer constructor, in #421 , thanks to @user01010111
- ๐ Clarify that the name given to
add_render_rule must match a token type in #432 , thanks to @hikmetba-bit
- ๐ Fix typos and use HTTPS for the CommonMark spec links in #402 , #407 and #408 , thanks to @nikolas , @maxtaran2010 and @deeferentleeg
๐ง Maintenance
- ๐ง Publish to PyPI with trusted publishing and attestations, uploading distributions built with
python -m build and checked on every pull request, in #397 and #461
- ๐ง Include
tests/ in the sdist (next to tox.ini and CHANGELOG.md), so packagers can run the test suite from it, in #426 , thanks to @BetterAndBetterII (#420 ), and #461 ; requested by @mtelka in #261
- ๐ง Move
coverage and pytest-cov from the testing extra to a new coverage extra, and skip the linkify tests when linkify-it-py is not installed, in #463 ; requested by @befeleme in #195
- ๐ง Read the CommonMark spec fixtures as UTF-8, so the tests pass on Windows with a non-UTF-8 locale, in #454 , thanks to @Aschenbath
- ๐ง Drop the optional dependency on the unmaintained
commonmark package from the compare extra in #427 , thanks to @nikolas (#401 )
- ๐ง Build the documentation on Python 3.13 and Sphinx 9 in #462
Upgrade notes
- Rules that do not advance now raise.
A block or inline rule that returns
True without moving state.line or state.pos forward now raises RuntimeError (block rule didn't increment state.line, inline rule didn't increment state.pos), where it used to hang.
So does a line that no block rule accepts, which is only possible with the paragraph rule disabled (none of the block rules matched).
- Image
children hold joined text tokens.
As in markdown-it 15, text_join now also joins the text_special tokens among an image token's children, so code that reads alt text from them gets escaped characters and entities as plain text tokens (a nested image's own children are still not joined, as upstream).
- Render rules must return
str.
The rendered fragments are now joined with str.join, so a rule that returns a str subclass (such as markupsafe.Markup) gives a plain str from render(), and any non-str result (even one that defines __radd__, which 4.2.0 let through) raises TypeError when the fragments are joined.
SyntaxTreeNode.to_tokens() follows the tree.
The tree's children are the source of truth: a change made directly to a token's children list no longer appears in the output, and to_tokens() does not modify the token stream the tree was built from.
- Rule names given as a generator to
MarkdownIt.enable() or disable() are validated like a list, so an unknown name now raises ValueError.
- Internals plugins may touch.
StateInline.pending is now a property backed by a buffer: state.pending += text still works, and the new state.append_pending(text) appends in constant time.
HTML_TAG_RE (markdown_it.common.html_re) and DIGITAL_RE and NAMED_RE (markdown_it.rules_inline.entity) no longer start with ^, because they are applied with .match(src, pos); code that calls .search() on them now matches anywhere in the string.
The private StateBase._src and _srcCharCode attributes are gone (srcCharCode itself is still there, and still deprecated).
- Packaging.
The
testing extra no longer installs coverage and pytest-cov: install .[testing,coverage] to run the tests with --cov.
The sdist now contains tests/, and no longer contains repository files such as .github/, .pre-commit-config.yaml and scripts/.
Full Changelog : https://github.com/executablebooks/markdown-it-py/compare/v4.2.0...v4.3.0
4.2.0 - 2026-05-07
- โจ Add
make_fence_rule() factory for configurable fence markers in #394
Full Changelog : https://github.com/executablebooks/markdown-it-py/compare/v4.1.0...v4.2.0
4.1.0 - 2026-05-06
- โจ Add
gfm-like2 preset with task lists, alerts, and single-tilde strikethrough core plugins in #388
- โจ Allow plugins to register inline terminator characters in #391
- ๐ Fix quadratic complexity in
fragments_join / text_join in #389 , thanks to @petricevich
- ๐ Add
--stdin option to CLI for reading Markdown from standard input in #379 , thanks to @mcepl
- ๐ง Add typing to Scanner in #382 , thanks to @Alunderin
Full Changelog : https://github.com/executablebooks/markdown-it-py/compare/v4.0.0...v4.1.0
4.0.0 - 2025-08-11
This primarily drops support for Python 3.9, adds support for Python 3.13,
and updates the parser to comply with Commonmark 0.31.2 and Markdown-It v14.1.0.
- โฌ๏ธ Drop support for Python 3.9 in #360
- โฌ๏ธ Comply with Commonmark 0.31.2 in #362
- ๐ Improve performance of "text" inline rule in #347
- ๐ Use
str.removesuffix in #348
- ๐ limit the number of autocompleted cells in a table in #364
- ๐ fix quadratic complexity in reference parser in #367
- ๐ Fix emphasis inside raw links bugs in #320
Full Changelog : https://github.com/executablebooks/markdown-it-py/compare/v3.0.0...v4.0.0
3.0.0 - 2023-06-03
โ ๏ธ This release contains some minor breaking changes in the internal API and improvements to the parsing strictness.
Full Changelog : https://github.com/executablebooks/markdown-it-py/compare/v2.2.0...v3.0.0
โฌ๏ธ UPGRADE: Drop support for Python 3.7
Also add testing for Python 3.11
โฌ๏ธ UPGRADE: Update from upstream markdown-it 12.2.0 to 13.0.0
A key change is the addition of a new Token type, text_special, which is used to represent HTML entities and backslash escaped characters.
This ensures that (core) typographic transformation rules are not incorrectly applied to these texts.
The final core rule is now the new text_join rule, which joins adjacent text/text_special tokens,
and so no text_special tokens should be present in the final token stream.
Any custom typographic rules should be inserted before text_join.
A new linkify rule has also been added to the inline chain, which will linkify full URLs (e.g. https://example.com),
and fixes collision of emphasis and linkifier (so http://example.org/foo._bar_-_baz is now a single link, not emphasized).
Emails and fuzzy links are not affected by this.
- โป๏ธ Refactor backslash escape logic, add
text_special #276
- โป๏ธ Parse entities to
text_special token #280
- โป๏ธ Refactor: Add linkifier rule to inline chain for full links #279
- โผ๏ธ Remove
(p) => ยง replacement in typographer #281
- โผ๏ธ Remove unused
silent arg in ParserBlock.tokenize #284
- ๐ FIX: numeric character reference passing #272
- ๐ Fix: tab preventing paragraph continuation in lists #274
- ๐ Improve nested emphasis parsing #273
- ๐ fix possible ReDOS in newline rule #275
- ๐ Improve performance of
skipSpaces/skipChars #271
- ๐ Show text of
text_special in tree.pretty #282
โป๏ธ REFACTOR: Replace most character code use with strings
The use of StateBase.srcCharCode is deprecated (with backward-compatibility), and all core uses are replaced by StateBase.src.
Conversion of source string characters to an integer representing the Unicode character is prevalent in the upstream JavaScript implementation, to improve performance.
However, it is unnecessary in Python and leads to harder to read code and performance deprecations (during the conversion in the StateBase initialisation).
See #270 , thanks to @hukkinj1 .
โป๏ธ Centralise indented code block tests
For CommonMark, the presence of indented code blocks prevent any other block element from having an indent of greater than 4 spaces.
Certain Markdown flavors and derivatives, such as mdx and djot, disable these code blocks though, since it is more common to use code fences and/or arbitrary indenting is desirable.
Previously, disabling code blocks did not remove the indent limitation, since most block elements had the 3 space limitation hard-coded.
This change centralised the logic of applying this limitation (in StateBlock.is_code_block), and only applies it when indented code blocks are enabled.
This allows for e.g.
<div>
<div>
I can indent as much as I want here.
<div>
<div>
See #260
๐ง Maintenance changes
Strict type annotation checking has been applied to the whole code base,
ruff is now used for linting,
and fuzzing tests have been added to the CI, to integrate with Google OSS-Fuzz testing, thanks to @DavidKorczynski .
- ๐ง MAINTAIN: Make type checking strict #
- ๐ง Add typing of rule functions #283
- ๐ง Move linting from flake8 to ruff #268
- ๐งช CI: Add fuzzing workflow for PRs #262
- ๐ง Add tox env for fuzz testcase run #263
- ๐งช Add OSS-Fuzz set up by @DavidKorczynski in #255
- ๐งช Fix fuzzing test failures #254
2.2.0 - 2023-02-22
What's Changed
- โฌ๏ธ UPGRADE: Allow linkify-it-py v2 by @hukkin in #218
- ๐ FIX: CVE-2023-26303 by @chrisjsewell in #246
- ๐ FIX: CLI crash on non-utf8 character by @chrisjsewell in #247
- ๐ DOCS: Update the example by @redstoneleo in #229
- ๐ DOCS: Add section about markdown renderer by @holamgadol in #227
- ๐ง Create SECURITY.md by @chrisjsewell in #248
- ๐ง MAINTAIN: Update mypy's additional dependencies by @hukkin in #217
- Fix typo by @jwilk in #230
- ๐ง Bump GH actions by @chrisjsewell in #244
- ๐ง Update benchmark pkg versions by @chrisjsewell in #245
New Contributors
Thanks to ๐
- @jwilk made their first contribution in #230
- @holamgadol made their first contribution in #227
- @redstoneleo made their first contribution in #229
Full Changelog : https://github.com/executablebooks/markdown-it-py/compare/v2.1.0...v2.2.0
2.1.0 - 2022-04-15
This release is primarily to replace the attrs package dependency,
with the built-in Python dataclasses package.
This should not be a breaking change, for most use cases.
- โฌ๏ธ UPGRADE: Drop support for EOL Python 3.6 (#194)
- โป๏ธ REFACTOR: Move
Rule/Delimiter classes from attrs to dataclass (#211)
- โป๏ธ REFACTOR: Move
Token class from attrs to dataclass (#211)
- โผ๏ธ Remove deprecated
NestedTokens and nest_tokens
- โจ NEW: Save ordered list numbering (#192)
- ๐ FIX: Combination of blockquotes, list and newlines causes
IndexError (#207)
2.0.1 - 2022-01-24
- ๐ FIX: Crash when file ends with empty blockquote line.
- โจ NEW: Add
inline_definitions option.
This option allows for definition token to be inserted into the token stream, at the point where the definition is located in the source text.
It is useful for cases where one wishes to capture a "loseless" syntax tree of the parsed Markdown (in conjunction with the store_labels option).
2.0.0 - 2021-12-03
- โฌ๏ธ Update: Sync with markdown-it v12.1.0 and CommonMark v0.30
- โป๏ธ REFACTOR: Port
mdurl and punycode for URL normalisation (thanks to @hukkin!).
This port fixes the outstanding CommonMark compliance tests.
- โป๏ธ REFACTOR: Remove
AttrDict.
This is no longer used is core or mdit-py-plugins, instead standard dictionaries are used.
- ๐ IMPROVE: Use
__all__ to signal re-exports
1.1.0 - 2021-05-08
โฌ๏ธ UPGRADE: attrs -> v21 (#165)
This release has no breaking changes
(see: https://github.com/python-attrs/attrs/blob/main/CHANGELOG.rst )
1.0.0 - 2021-05-02
Full commit log
The first stable release of markdown-it-py ๐
See the changes in the beta releases below,
thanks to all the contributors in the last year!
1.0.0b3 - 2021-05-01
- ๐ IMPROVE: Add
RendererProtocol type, for typing renderers (thanks to @hukkinj1 )
- ๐ง MAINTAIN:
None is no longer allowed as a valid src input for StateBase subclasses
1.0.0b2 - 2021-04-25
โผ๏ธ BREAKING: Move mdit-py-plugins out of the core install requirements and into a plugins extra.
Synchronised code with the upstream Markdown-It v12.0.6:
- ๐ FIX: Raise HTML blocks priority to resolve conflict with headings
- ๐ FIX: Newline not rendered in image alt attribute
1.0.0b1 - 2021-03-31
Full commit log
This is the first beta release of the stable v1.x series.
There are four notable (and breaking) changes:
- The code has been synchronised with the upstream Markdown-It
v12.0.4.
In particular, this update alters the parsing of tables to be consistent with the GFM specification: https://github.github.com/gfm/#tables-extension-
A number of parsing performance and validation improvements are also included.
Token.attrs are now stored as dictionaries, rather than a list of lists.
This is a departure from upstream Markdown-It, allowed by Pythons guarantee of ordered dictionaries (see #142 ), and is the more natural representation.
Note attrGet, attrSet, attrPush and attrJoin methods remain identical to those upstream,
and Token.as_dict(as_upstream=True) will convert the token back to a directly comparable dict.
- The use of
AttrDict has been replaced:
For env any Python mutable mapping is now allowed, and so attribute access to keys is not (differing from the Javascript dictionary).
For MarkdownIt.options it is now set as an OptionsDict, which is a dictionary sub-class, with attribute access only for core MarkdownIt configuration keys.
- Introduction of the
SyntaxTreeNode.
This is a more comprehensive replacement for nest_tokens and NestedTokens (which are now deprecated).
It allows for the Token stream to be converted to/from a nested tree structure, with opening/closing tokens collapsed into a single SyntaxTreeNode and the intermediate tokens set as children.
See Creating a syntax tree documentation for details.
Additional Fixes ๐
- Fix exception due to empty lines after blockquote+footnote
- Fix linkify link nesting levels
- Fix the use of
Ruler.at for plugins
- Avoid fenced token mutations during rendering
- Fix CLI version info and correct return of exit codes
0.6.2 - 2021-02-07
This release brings Markdown-It-Py inline with Markdown-It v11.0.1 (2020-09-14), applying two fixes:
- Fix blockquote lazy newlines, [#696 ].
- Fix missed mappings for table rows, [#705 ].
Thanks to @hukkinj1 !
0.6.1 - 2021-01-01
This release provides some improvements to the code base:
- ๐ FIX: Do not resolve backslash escapes inside auto-links
- ๐ FIX: Add content to image tokens
- ๐ IMPROVE: Add more type annotations, thanks to @hukkinj1
0.6.0 - 2020-12-15
๐ DEPRECATE: Move plugins to mdit_py_plugins
Plugins (in markdown_it.extensions) have now been moved to executablebooks/mdit-py-plugins .
This will allow for their maintenance to occur on a different cycle to the core code, facilitating the release of a v1.0.0 for this package
๐ง MAINTAIN: Add mypy type-checking, thanks to @hukkinj1 .
0.5.8 - 2020-12-13
โจ NEW: Add linkify, thanks to @tsutsu3 .
This extension uses linkify-it-py to identify URL links within text:
github.com -> <a href="http://github.com">github.com</a>
Important: To use this extension you must install linkify-it-py; pip install markdown-it-py[linkify]
It can then be activated by:
from markdown_it import MarkdownIt
md = MarkdownIt().enable("linkify")
md.options["linkify"] = True
0.5.7 - 2020-12-13
โจ NEW: Add smartquotes, thanks to @tsutsu3 .
This extension will convert basic quote marks to their opening and closing variants:
- 'single quotes' -> 'single quotes'
- "double quotes" -> "double quotes"
It can be activated by:
from markdown_it import MarkdownIt
md = MarkdownIt().enable("smartquotes")
md.options["typographer"] = True
โจ NEW: Add markdown-it-task-lists plugin, thanks to @wna-se .
This is a port of the JS markdown-it-task-lists ,
for building task/todo lists out of markdown lists with items starting with [ ] or [x].
For example:
- [ ] An item that needs doing
- [x] An item that is complete
This plugin can be activated by:
from markdown_it import MarkdownIt
from markdown_it.extensions.tasklists import tasklists_plugin
md = MarkdownIt().use(tasklists_plugin)
๐ Various bug fixes, thanks to @hukkinj1 :
- Do not copy empty
env arg in MarkdownIt.render
_Entities.__contains__ fix return data
- Parsing of unicode ordinals
- Handling of final character in
skipSpacesBack and skipCharsBack methods
- Avoid exception when document ends in heading/blockquote marker
๐งช TESTS: Add CI for Python 3.9 and PyPy3
0.5.6 - 2020-10-21
-
โจ NEW: Add simple typographic replacements, thanks to @tsutsu3 :
This allows you to add the typographer option to the parser, to replace particular text constructs:
(c), (C) โ ยฉ
(tm), (TM) โ โข
(r), (R) โ ยฎ
(p), (P) โ ยง
+- โ ยฑ
... โ ...
?.... โ ?..
!.... โ !..
???????? โ ???
!!!!! โ !!!
,,, โ ,
-- โ &ndash
--- โ &mdash
md = MarkdownIt().enable("replacements")
md.options["typographer"] = True
-
๐ DOCS: Improve documentation for CLI, thanks to @westurner
-
๐ IMPROVE: Use re.sub() instead of re.subn()[0], thanks to @hukkinj1
-
๐ FIX: An exception raised by having multiple blank lines at the end of some files
0.5.5 - 2020-09-27
๐ IMPROVE: Add store_labels option.
This allows for storage of original reference label in link/image token's metadata,
which can be useful for renderers.
0.5.4 - 2020-09-08
โจ NEW: Add anchors_plugin for headers, which can produce:
<h1 id="title-string">Title String <a class="header-anchor" href="#title-string">ยถ</a></h1>
0.5.3 - 2020-09-04
๐ Fixed an undefined variable in the reference block.
0.5.2 - 2020-08-22
๐ Fixed an IndexError in container_plugin, when there is no newline on the closing tag line.
0.5.1 - 2020-08-21
โฌ๏ธ UPGRADE: attrs -> v20
This is not breaking, since it only deprecates Python 3.4 (see CHANGELOG.rst )
0.5.0 - 2020-08-18
Added โจ
Improved ๐
Fixed ๐
- Stopped empty lines at the end of the document, after certain list blocks, raising an exception (#36).
- Allow myst-role to accept names containing digits (0-9).
0.4.9 - 2020-08-11
Added โจ
Documented ๐
- Plugins and improved contributing section