| 1 |
title: Changelog |
| 2 |
toc_depth: 2 |
| 3 |
|
| 4 |
# Python-Markdown Changelog |
| 5 |
|
| 6 |
All notable changes to this project will be documented in this file. |
| 7 |
|
| 8 |
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), |
| 9 |
and this project adheres to the |
| 10 |
[Python Version Specification](https://packaging.python.org/en/latest/specifications/version-specifiers/). |
| 11 |
See the [Contributing Guide](contributing.md) for details. |
| 12 |
|
| 13 |
## [3.10.3] - 2026-07-30 |
| 14 |
|
| 15 |
### Fixed |
| 16 |
|
| 17 |
* Fix `SetextHeaderProcessor` regex to prevent mixed `=` and `-` chars in setext-style headers (#1606). |
| 18 |
* Add AI Policy to Contributing Guide. |
| 19 |
* Officially document all included extensions as being in maintenance mode. |
| 20 |
* Link the Extension API documentation to the API Reference (#1612). |
| 21 |
|
| 22 |
## [3.10.2] - 2026-02-09 |
| 23 |
|
| 24 |
### Fixed |
| 25 |
|
| 26 |
* Fix a regression related to comment handling (#1590). |
| 27 |
* More reliable fix for `</` (#1593). |
| 28 |
|
| 29 |
## [3.10.1] - 2026-01-21 |
| 30 |
|
| 31 |
### Fixed |
| 32 |
|
| 33 |
* Ensure nested elements inside inline comments are properly unescaped (#1571). |
| 34 |
* Make the docs build successfully with mkdocstrings-python 2.0 (#1575). |
| 35 |
* Fix infinite loop when multiple bogus or unclosed HTML comments appear in input (#1578). |
| 36 |
* Fix another infinite loop when handling bad comments (#1586). |
| 37 |
|
| 38 |
## [3.10.0] - 2025-11-03 |
| 39 |
|
| 40 |
### Changed |
| 41 |
|
| 42 |
* Officially support Python 3.14 and PyPy 3.11 and drop support for Python 3.9 |
| 43 |
and PyPy 3.9. |
| 44 |
|
| 45 |
### Fixed |
| 46 |
|
| 47 |
* Fix an HTML comment parsing case in some Python versions that can cause an |
| 48 |
infinite loop (#1554). |
| 49 |
* Revert the default behavior of `USE_DEFINITION_ORDER` (to `True`). The new |
| 50 |
behavior introduced in 3.9.0 is experimental and results are inconsistent. |
| 51 |
It should not have been made the default behavior (#1561). |
| 52 |
|
| 53 |
## [3.9.0] - 2025-09-04 |
| 54 |
|
| 55 |
### Changed |
| 56 |
|
| 57 |
* Footnotes are now ordered by the occurrence of their references in the |
| 58 |
document. A new configuration option for the footnotes extension, |
| 59 |
`USE_DEFINITION_ORDER`, has been added to support restoring the previous |
| 60 |
behavior of ordering footnotes by the occurrence of definitions (#1367). |
| 61 |
|
| 62 |
### Fixed |
| 63 |
|
| 64 |
* Ensure inline processing iterates through elements in document order (#1546). |
| 65 |
* Fix handling of incomplete HTML tags in code spans in Python 3.14 (#1547). |
| 66 |
|
| 67 |
## [3.8.2] - 2025-06-19 |
| 68 |
|
| 69 |
### Fixed |
| 70 |
|
| 71 |
* Fix `codecs` deprecation in Python 3.14 (#1537). |
| 72 |
* Fix issue with unclosed comment parsing in Python 3.14 (#1537). |
| 73 |
* Fix issue with unclosed declarations in Python 3.14 (#1537). |
| 74 |
* Fix issue with unclosed HTML tag `<foo` and Python 3.14 (#1537). |
| 75 |
|
| 76 |
## [3.8.1] - 2025-06-18 |
| 77 |
|
| 78 |
### Fixed |
| 79 |
|
| 80 |
* Ensure incomplete markup declaration in raw HTML doesn't crash parser (#1534). |
| 81 |
* Fixed dropped content in `md_in_html` (#1526). |
| 82 |
* Fixed HTML handling corner case that prevented some content from not being rendered (#1528). |
| 83 |
|
| 84 |
## [3.8.0] - 2025-04-09 |
| 85 |
|
| 86 |
### Changed |
| 87 |
|
| 88 |
* DRY fix in `abbr` extension by introducing method `create_element` (#1483). |
| 89 |
* Clean up test directory by removing some redundant tests and port |
| 90 |
non-redundant cases to the newer test framework. |
| 91 |
* Improved performance of the raw HTML post-processor (#1510). |
| 92 |
|
| 93 |
### Fixed |
| 94 |
|
| 95 |
* Backslash Unescape IDs set via `attr_list` on `toc` (#1493). |
| 96 |
* Ensure `md_in_html` processes content inside "markdown" blocks as they are |
| 97 |
parsed outside of "markdown" blocks to keep things more consistent for |
| 98 |
third-party extensions (#1503). |
| 99 |
* `md_in_html` handle tags within inline code blocks better (#1075). |
| 100 |
* `md_in_html` fix handling of one-liner block HTML handling (#1074). |
| 101 |
* Ensure `<center>` is treated like a block-level element (#1481). |
| 102 |
* Ensure that `abbr` extension respects `AtomicString` and does not process |
| 103 |
perceived abbreviations in these strings (#1512). |
| 104 |
* Ensure `smarty` extension correctly renders nested closing quotes (#1514). |
| 105 |
|
| 106 |
## [3.7.0] - 2024-08-16 |
| 107 |
|
| 108 |
### Changed |
| 109 |
|
| 110 |
* Refactor `abbr` Extension |
| 111 |
|
| 112 |
A new `AbbrTreeprocessor` has been introduced, which replaces the now deprecated |
| 113 |
`AbbrInlineProcessor`. Abbreviation processing now happens after Attribute Lists, |
| 114 |
avoiding a conflict between the two extensions (#1460). |
| 115 |
|
| 116 |
The `AbbrPreprocessor` class has been renamed to `AbbrBlockprocessor`, which |
| 117 |
better reflects what it is. `AbbrPreprocessor` has been deprecated. |
| 118 |
|
| 119 |
A call to `Markdown.reset()` now clears all previously defined abbreviations. |
| 120 |
|
| 121 |
Abbreviations are now sorted by length before executing `AbbrTreeprocessor` |
| 122 |
to ensure that multi-word abbreviations are implemented even if an abbreviation |
| 123 |
exists for one of those component words. (#1465) |
| 124 |
|
| 125 |
Abbreviations without a definition are now ignored. This avoids applying |
| 126 |
abbr tags to text without a title value. |
| 127 |
|
| 128 |
Added an optional `glossary` configuration option to the abbreviations extension. |
| 129 |
This provides a simple and efficient way to apply a dictionary of abbreviations |
| 130 |
to every page. |
| 131 |
|
| 132 |
Abbreviations can now be disabled by setting their definition to `""` or `''`. |
| 133 |
This can be useful when using the `glossary` option. |
| 134 |
|
| 135 |
### Fixed |
| 136 |
|
| 137 |
* Fixed links to source code on GitHub from the documentation (#1453). |
| 138 |
|
| 139 |
## [3.6.0] - 2024-03-14 |
| 140 |
|
| 141 |
### Changed |
| 142 |
|
| 143 |
* Refactor TOC Sanitation |
| 144 |
|
| 145 |
* All postprocessors are now run on heading content. |
| 146 |
* Footnote references are now stripped from heading content. Fixes #660. |
| 147 |
* A more robust `striptags` is provided to convert headings to plain text. |
| 148 |
Unlike, the `markupsafe` implementation, HTML entities are not unescaped. |
| 149 |
* The plain text `name`, rich `html`, and unescaped raw `data-toc-label` are |
| 150 |
saved to `toc_tokens`, allowing users to access the full rich text content of |
| 151 |
the headings directly from `toc_tokens`. |
| 152 |
* The value of `data-toc-label` is sanitized separate from heading content |
| 153 |
before being written to `name`. This fixes a bug which allowed markup through |
| 154 |
in certain circumstances. To access the raw unsanitized data, retrieve the |
| 155 |
value from `token['data-toc-label']` directly. |
| 156 |
* An `html.unescape` call is made just prior to calling `slugify` so that |
| 157 |
`slugify` only operates on Unicode characters. Note that `html.unescape` is |
| 158 |
not run on `name`, `html`, or `data-toc-label`. |
| 159 |
* The functions `get_name` and `stashedHTML2text` defined in the `toc` extension |
| 160 |
are both **deprecated**. Instead, third party extensions should use some |
| 161 |
combination of the new functions `run_postprocessors`, `render_inner_html` and |
| 162 |
`striptags`. |
| 163 |
|
| 164 |
### Fixed |
| 165 |
|
| 166 |
* Include `scripts/*.py` in the generated source tarballs (#1430). |
| 167 |
* Ensure lines after heading in loose list are properly detabbed (#1443). |
| 168 |
* Give smarty tree processor higher priority than toc (#1440). |
| 169 |
* Permit carets (`^`) and square brackets (`]`) but explicitly exclude |
| 170 |
backslashes (`\`) from abbreviations (#1444). |
| 171 |
* In attribute lists (`attr_list`, `fenced_code`), quoted attribute values are |
| 172 |
now allowed to contain curly braces (`}`) (#1414). |
| 173 |
|
| 174 |
## [3.5.2] - 2024-01-10 |
| 175 |
|
| 176 |
### Fixed |
| 177 |
|
| 178 |
* Fix type annotations for `convertFile` - it accepts only bytes-based buffers. |
| 179 |
Also remove legacy checks from Python 2 (#1400) |
| 180 |
* Remove legacy import needed only in Python 2 (#1403) |
| 181 |
* Fix typo that left the attribute `AdmonitionProcessor.content_indent` unset |
| 182 |
(#1404) |
| 183 |
* Fix edge-case crash in `InlineProcessor` with `AtomicString` (#1406). |
| 184 |
* Fix edge-case crash in `codehilite` with an empty `code` tag (#1405). |
| 185 |
* Improve and expand type annotations in the code base (#1401). |
| 186 |
* Fix handling of bogus comments (#1425). |
| 187 |
|
| 188 |
## [3.5.1] - 2023-10-31 |
| 189 |
|
| 190 |
### Fixed |
| 191 |
|
| 192 |
* Fix a performance problem with HTML extraction where large HTML input could |
| 193 |
trigger quadratic line counting behavior (#1392). |
| 194 |
* Improve and expand type annotations in the code base (#1394). |
| 195 |
|
| 196 |
## [3.5.0] - 2023-10-06 |
| 197 |
|
| 198 |
### Added |
| 199 |
|
| 200 |
* Add `permalink_leading` configuration option to the toc extension (#1339) |
| 201 |
|
| 202 |
A new boolean option `permalink_leading` controls the position of the permanent |
| 203 |
link anchors generated with `permalink`. Setting `permalink_leading` to `True` |
| 204 |
will cause the links to be inserted at the start of the header, before any other |
| 205 |
header content. The default behavior for `permalink` is to append permanent |
| 206 |
links to the header, placing them after all other header content. |
| 207 |
|
| 208 |
### Changed |
| 209 |
|
| 210 |
* Add support for cPython version 3.12 (and PyPy 3.10) and drop support for |
| 211 |
Python version 3.7 (#1357). |
| 212 |
* Refactor changelog to use the format defined at <https://keepachangelog.com/>. |
| 213 |
* Update the list of empty HTML tags (#1353). |
| 214 |
* Add customizable TOC title class to TOC extension (#1293). |
| 215 |
* Add API documentation of the code base which is generated by |
| 216 |
[mkdocstrings](https://mkdocstrings.github.io/) (#1220). |
| 217 |
|
| 218 |
### Fixed |
| 219 |
|
| 220 |
* Fix a corner case in admonitions where if an indented code block was provided |
| 221 |
as the first block, the output would be malformed (#1329). |
| 222 |
|
| 223 |
## [3.4.4] - 2023-07-25 |
| 224 |
|
| 225 |
### Fixed |
| 226 |
|
| 227 |
* Add a special case for initial `'s` to smarty extension (#1305). |
| 228 |
* Unescape any backslash escaped inline raw HTML (#1358). |
| 229 |
* Unescape backslash escaped TOC token names (#1360). |
| 230 |
|
| 231 |
## [3.4.3] - 2023-03-23 |
| 232 |
|
| 233 |
### Fixed |
| 234 |
|
| 235 |
* Restore console script (#1327). |
| 236 |
|
| 237 |
## [3.4.2] - 2023-03-22 |
| 238 |
|
| 239 |
### Fixed |
| 240 |
* Officially support Python 3.11. |
| 241 |
* Improve standalone * and _ parsing (#1300). |
| 242 |
* Consider `<html>` HTML tag a block-level element (#1309). |
| 243 |
* Switch from `setup.py` to `pyproject.toml`. |
| 244 |
|
| 245 |
## [3.4.1] - 2022-07-15 |
| 246 |
|
| 247 |
### Fixed |
| 248 |
|
| 249 |
* Fix an import issue with `importlib.util` (#1274). |
| 250 |
|
| 251 |
## [3.4.0] - 2022-07-15 |
| 252 |
|
| 253 |
### Changed |
| 254 |
|
| 255 |
* The `tables` extension now uses a `style` attribute instead of an `align` attribute for alignment. |
| 256 |
|
| 257 |
The [HTML4 spec](https://www.w3.org/TR/html4/present/graphics.html#h-15.1.2) |
| 258 |
specifically deprecates the use of the `align` attribute and it does not appear |
| 259 |
at all in the [HTML5 |
| 260 |
spec](https://www.w3.org/TR/html53/tabular-data.html#attributes-common-to-td-and-th-elements). |
| 261 |
Therefore, by default, the [tables](extensions/tables.md) extension will now use |
| 262 |
the `style` attribute (setting just the `text-align` property) in `td` and `th` |
| 263 |
blocks. |
| 264 |
|
| 265 |
The former behavior is available by setting the `use_align_attribute` |
| 266 |
configuration option to `True` when enabling the extension. |
| 267 |
|
| 268 |
For example, to configure the old `align` behavior: |
| 269 |
|
| 270 |
from markdown.extensions.tables import TableExtension |
| 271 |
|
| 272 |
markdown.markdown(src, extensions=[TableExtension(use_align_attribute=True)]) |
| 273 |
|
| 274 |
* Backslash unescaping moved to Treeprocessor (#1131). |
| 275 |
|
| 276 |
Unescaping backslash escapes has been moved to a Treeprocessor, which enables |
| 277 |
proper HTML escaping during serialization. However, it is recognized that |
| 278 |
various third-party extensions may be calling the old class at |
| 279 |
`postprocessors.UnescapePostprocessor`. Therefore, the old class remains in the |
| 280 |
code base, but has been deprecated and will be removed in a future release. The |
| 281 |
new class `treeprocessors.UnescapeTreeprocessor` should be used instead. |
| 282 |
|
| 283 |
* Previously deprecated objects have been removed |
| 284 |
|
| 285 |
Various objects were deprecated in version 3.0 and began raising deprecation |
| 286 |
warnings (see the [version 3.0 release notes](#300-2018-09-21) for details). Any of those objects |
| 287 |
which remained in version 3.3 have been removed from the code base in version 3.4 |
| 288 |
and will now raise errors. The relevant objects are listed below. |
| 289 |
|
| 290 |
|
| 291 |
| Deprecated Object | Replacement Object | |
| 292 |
|----------------------------------------|-------------------------------------| |
| 293 |
| `markdown.version` | `markdown.__version__` | |
| 294 |
| `markdown.version_info` | `markdown.__version_info__` | |
| 295 |
| `markdown.util.etree` | `xml.etree.ElementTree` | |
| 296 |
| `markdown.util.string_type` | `str` | |
| 297 |
| `markdown.util.text_type` | `str` | |
| 298 |
| `markdown.util.int2str` | `chr` | |
| 299 |
| `markdown.util.iterrange` | `range` | |
| 300 |
| `markdown.util.isBlockLevel` | `markdown.Markdown().is_block_level`| |
| 301 |
| `markdown.util.Processor().markdown` | `markdown.util.Processor().md` | |
| 302 |
| `markdown.util.Registry().__setitem__` | `markdown.util.Registry().register` | |
| 303 |
| `markdown.util.Registry().__delitem__` |`markdown.util.Registry().deregister`| |
| 304 |
| `markdown.util.Registry().add` | `markdown.util.Registry().register` | |
| 305 |
|
| 306 |
In addition, the `md_globals` parameter of |
| 307 |
`Markdown.extensions.Extension.extendMarkdown()` is no longer recognized as a |
| 308 |
valid parameter and will raise an error if provided. |
| 309 |
|
| 310 |
### Added |
| 311 |
|
| 312 |
* Some new configuration options have been added to the |
| 313 |
[footnotes](extensions/footnotes.md) extension (#1218): |
| 314 |
|
| 315 |
* Small refactor of the `BACKLINK_TITLE` option; The use of `format()` |
| 316 |
instead of "old" `%d` formatter allows one to specify text without the |
| 317 |
need to have the number of the footnote in it (like footnotes on |
| 318 |
Wikipedia for example). The modification is backward compatible so no |
| 319 |
configuration change is required. |
| 320 |
|
| 321 |
* Addition of a new option `SUPERSCRIPT_TEXT` that allows one to specify a |
| 322 |
custom placeholder for the footnote itself in the text. |
| 323 |
Ex: `[{}]` will give `<sup>[1]</sup>`, `({})` will give `<sup>(1)</sup>`, |
| 324 |
or by default, the current behavior: `<sup>1</sup>`. |
| 325 |
|
| 326 |
* The [Table of Contents](extensions/toc.md) extension now accepts a |
| 327 |
`toc_class` parameter which can be used to set the CSS class(es) on the |
| 328 |
`<div>` that contains the Table of Contents (#1224). |
| 329 |
|
| 330 |
* The CodeHilite extension now supports a `pygments_formatter` option that can |
| 331 |
be set to a custom formatter class (#1187). |
| 332 |
|
| 333 |
- If `pygments_formatter` is set to a string (ex: `'html'`), Pygments' |
| 334 |
default formatter by that name is used. |
| 335 |
- If `pygments_formatter` is set to a formatter class (or any callable |
| 336 |
which returns a formatter instance), then an instance of that class is |
| 337 |
used. |
| 338 |
|
| 339 |
The formatter class is now passed an additional option, `lang_str`, to |
| 340 |
denote the language of the code block (#1258). While Pygments' built-in |
| 341 |
formatters will ignore the option, a custom formatter assigned to the |
| 342 |
`pygments_formatter` option can make use of the `lang_str` to include the |
| 343 |
code block's language in the output. |
| 344 |
|
| 345 |
### Fixed |
| 346 |
|
| 347 |
* Extension entry-points are only loaded if needed (#1216). |
| 348 |
* Added additional checks to the `<pre><code>` handling of |
| 349 |
`PrettifyTreeprocessor` (#1261, #1263). |
| 350 |
* Fix XML deprecation warnings. |
| 351 |
|
| 352 |
## [3.3.7] - 2022-05-05 |
| 353 |
|
| 354 |
### Fixed |
| 355 |
|
| 356 |
* Disallow square brackets in reference link ids (#1209). |
| 357 |
* Retain configured `pygments_style` after first code block (#1240). |
| 358 |
* Ensure fenced code attributes are properly escaped (#1247). |
| 359 |
|
| 360 |
## [3.3.6] - 2021-11-17 |
| 361 |
|
| 362 |
### Fixed |
| 363 |
|
| 364 |
* Fix a dependency issue (#1195, #1196). |
| 365 |
|
| 366 |
## [3.3.5] - 2021-11-16 |
| 367 |
|
| 368 |
### Fixed |
| 369 |
|
| 370 |
* Make the `slugify_unicode` function not remove diacritical marks (#1118). |
| 371 |
* Fix `[toc]` detection when used with `nl2br` extension (#1160). |
| 372 |
* Re-use compiled regex for block level checks (#1169). |
| 373 |
* Don't process shebangs in fenced code blocks when using CodeHilite (#1156). |
| 374 |
* Improve email address validation for Automatic Links (#1165). |
| 375 |
* Ensure `<summary>` tags are parsed correctly (#1079). |
| 376 |
* Support Python 3.10 (#1124). |
| 377 |
|
| 378 |
## [3.3.4] - 2021-02-24 |
| 379 |
|
| 380 |
### Fixed |
| 381 |
|
| 382 |
* Properly parse unclosed tags in code spans (#1066). |
| 383 |
* Properly parse processing instructions in md_in_html (#1070). |
| 384 |
* Properly parse code spans in md_in_html (#1069). |
| 385 |
* Preserve text immediately before an admonition (#1092). |
| 386 |
* Simplified regex for HTML placeholders (#928) addressing (#932). |
| 387 |
* Ensure `permalinks` and `anchorlinks` are not restricted by `toc_depth` (#1107). |
| 388 |
* Fix corner cases with lists under admonitions (#1102). |
| 389 |
|
| 390 |
## [3.3.3] - 2020-10-25 |
| 391 |
|
| 392 |
### Fixed |
| 393 |
|
| 394 |
* Unify all block-level tags (#1047). |
| 395 |
* Fix issue where some empty elements would have text rendered as `None` when using `md_in_html` (#1049). |
| 396 |
* Avoid catastrophic backtracking in `hr` regex (#1055). |
| 397 |
* Fix `hr` HTML handling (#1053). |
| 398 |
|
| 399 |
## [3.3.2] - 2020-10-19 |
| 400 |
|
| 401 |
### Fixed |
| 402 |
|
| 403 |
* Properly parse inline HTML in md_in_html (#1040 & #1045). |
| 404 |
* Avoid crashing when md_in_html fails (#1040). |
| 405 |
|
| 406 |
## [3.3.1] - 2020-10-12 |
| 407 |
|
| 408 |
### Fixed |
| 409 |
|
| 410 |
* Correctly parse raw `script` and `style` tags (#1036). |
| 411 |
* Ensure consistent class handling by `fenced_code` and `codehilite` (#1032). |
| 412 |
|
| 413 |
## [3.3.0] - 2020-10-06 |
| 414 |
|
| 415 |
### Changed |
| 416 |
|
| 417 |
* The prefix `language-` is now prepended to all language classes by default on code blocks. |
| 418 |
|
| 419 |
The [HTML5 |
| 420 |
spec](https://www.w3.org/TR/html5/text-level-semantics.html#the-code-element) |
| 421 |
recommends that the class defining the language of a code block be prefixed with |
| 422 |
`language-`. Therefore, by default, both the |
| 423 |
[fenced_code](extensions/fenced_code_blocks.md) and |
| 424 |
[codehilite](extensions/code_hilite.md) extensions now prepend the prefix when |
| 425 |
code highlighting is disabled. |
| 426 |
|
| 427 |
If you have previously been including the prefix manually in your fenced code blocks, then you will not want a second |
| 428 |
instance of the prefix. Similarly, if you are using a third party syntax highlighting tool which does not recognize |
| 429 |
the prefix, or requires a different prefix, then you will want to redefine the prefix globally using the `lang_prefix` |
| 430 |
configuration option of either the `fenced_code` or `codehilite` extensions. |
| 431 |
|
| 432 |
For example, to configure `fenced_code` to not apply any prefix (the previous behavior), set the option to an empty string: |
| 433 |
|
| 434 |
from markdown.extensions.fenced_code import FencedCodeExtension |
| 435 |
|
| 436 |
markdown.markdown(src, extensions=[FencedCodeExtension(lang_prefix='')]) |
| 437 |
|
| 438 |
!!! note |
| 439 |
When code highlighting is |
| 440 |
[enabled](extensions/fenced_code_blocks.md#enabling-syntax-highlighting), |
| 441 |
the output from Pygments is used unaltered. Currently, Pygments does not |
| 442 |
provide an option to include the language class in the output, let alone |
| 443 |
prefix it. Therefore, any language prefix is only applied when syntax |
| 444 |
highlighting is disabled. |
| 445 |
|
| 446 |
* Attribute Lists are more strict (#898). |
| 447 |
|
| 448 |
Empty curly braces are now completely ignored by the [Attribute List](extensions/attr_list.md) extension. Previously, the extension would |
| 449 |
recognize them as attribute lists and remove them from the document. Therefore, it is no longer necessary to backslash |
| 450 |
escape a set of curly braces which are empty or only contain whitespace. |
| 451 |
|
| 452 |
Despite not being documented, previously an attribute list could be defined anywhere within a table cell and get |
| 453 |
applied to the cell (`<td>` element). Now the attribute list must be defined at the end of the cell content and must |
| 454 |
be separated from the rest of the content by at least one space. This makes it easy to differentiate between attribute |
| 455 |
lists defined on inline elements within a cell and the attribute list for the cell itself. It is also more consistent |
| 456 |
with how attribute lists are defined on other types of elements. |
| 457 |
|
| 458 |
The extension has also added support for defining attribute lists on table header cells (`<th>` elements) in the same |
| 459 |
manner as data cells (`<td>` elements). |
| 460 |
|
| 461 |
In addition, the documentation for the extensions received an overhaul. The features (#987) and limitations (#965) of the extension are now fully documented. |
| 462 |
|
| 463 |
### Added |
| 464 |
|
| 465 |
* All Pygments' options are now available for syntax highlighting (#816). |
| 466 |
- The [Codehilite](extensions/code_hilite.md) extension now accepts any options |
| 467 |
which Pygments supports as global configuration settings on the extension. |
| 468 |
- [Fenced Code Blocks](extensions/fenced_code_blocks.md) will accept any of the |
| 469 |
same options on individual code blocks. |
| 470 |
- Any of the previously supported aliases to Pygments' options continue to be |
| 471 |
supported at this time. However, it is recommended that the Pygments option names |
| 472 |
be used directly to ensure continued compatibility in the future. |
| 473 |
|
| 474 |
* [Fenced Code Blocks](extensions/fenced_code_blocks.md) now work with |
| 475 |
[Attribute Lists](extensions/attr_list.md) when syntax highlighting is disabled. |
| 476 |
Any random HTML attribute can be defined and set on the `<code>` tag of fenced code |
| 477 |
blocks when the `attr_list` extension is enabled (#816). |
| 478 |
|
| 479 |
* The HTML parser has been completely replaced. The new HTML parser is built on Python's |
| 480 |
[`html.parser.HTMLParser`](https://docs.python.org/3/library/html.parser.html), which |
| 481 |
alleviates various bugs and simplify maintenance of the code (#803, #830). |
| 482 |
|
| 483 |
* The [Markdown in HTML](extensions/md_in_html.md) extension has been rebuilt on the |
| 484 |
new HTML Parser, which drastically simplifies it. Note that raw HTML elements with a |
| 485 |
`markdown` attribute defined are now converted to ElementTree Elements and are rendered |
| 486 |
by the serializer. Various bugs have been fixed (#803, #595, #780, and #1012). |
| 487 |
|
| 488 |
* Link reference parsing, abbreviation reference parsing and footnote reference parsing |
| 489 |
has all been moved from `preprocessors` to `blockprocessors`, which allows them to be |
| 490 |
nested within other block level elements. Specifically, this change was necessary to |
| 491 |
maintain the current behavior in the rebuilt Markdown in HTML extension. A few random |
| 492 |
edge-case bugs (see the included tests) were resolved in the process (#803). |
| 493 |
|
| 494 |
* An alternate function `markdown.extensions.headerid.slugify_unicode` has been included |
| 495 |
with the [Table of Contents](extensions/toc.md) extension which supports Unicode |
| 496 |
characters in table of contents slugs. The old `markdown.extensions.headerid.slugify` |
| 497 |
method which removes non-ASCII characters remains the default. Import and pass |
| 498 |
`markdown.extensions.headerid.slugify_unicode` to the `slugify` configuration option |
| 499 |
to use the new behavior. |
| 500 |
|
| 501 |
* Support was added for Python 3.9 and dropped for Python 3.5. |
| 502 |
|
| 503 |
### Fixed |
| 504 |
|
| 505 |
* Document how to pass configuration options to Extra (#1019). |
| 506 |
* Fix HR which follows strong em (#897). |
| 507 |
* Support short reference image links (#894). |
| 508 |
* Avoid a `RecursionError` from deeply nested blockquotes (#799). |
| 509 |
* Fix issues with complex emphasis (#979). |
| 510 |
* Fix unescaping of HTML characters `<>` in CodeHilite (#990). |
| 511 |
* Fix complex scenarios involving lists and admonitions (#1004). |
| 512 |
* Fix complex scenarios with nested ordered and unordered lists in a definition list (#918). |
| 513 |
|
| 514 |
## [3.2.2] - 2020-05-08 |
| 515 |
|
| 516 |
### Fixed |
| 517 |
|
| 518 |
* Add `checklinks` tox environment to ensure all links in documentation are good. |
| 519 |
* Refactor extension API documentation (#729). |
| 520 |
* Load entry_points (for extensions) only once using `importlib.metadata`. |
| 521 |
* Do not double escape entities in TOC. |
| 522 |
* Correctly report if an extension raises a `TypeError` (#939). |
| 523 |
* Raise a `KeyError` when attempting to delete a nonexistent key from the |
| 524 |
extension registry (#939). |
| 525 |
* Remove import of `packaging` (or `pkg_resources` fallback) entirely. |
| 526 |
* Remove `setuptools` as a run-time dependency (`install_required`). |
| 527 |
|
| 528 |
## [3.2.1] - 2020-02-12 |
| 529 |
|
| 530 |
### Fixed |
| 531 |
|
| 532 |
* The `name` property in `toc_tokens` from the TOC extension now |
| 533 |
escapes HTML special characters (`<`, `>`, and `&`). |
| 534 |
|
| 535 |
## [3.2.0] - 2020-02-07 |
| 536 |
|
| 537 |
### Changed |
| 538 |
|
| 539 |
* Drop support for Python 2.7 |
| 540 |
|
| 541 |
Python 2.7 reaches end-of-life on 2020-01-01 and Python-Markdown 3.2 has dropped |
| 542 |
support for it. Please upgrade to Python 3, or use Python-Markdown 3.1. |
| 543 |
|
| 544 |
* `em` and `strong` inline processor changes |
| 545 |
|
| 546 |
In order to fix issue #792, `em`/`strong` inline processors were refactored. This |
| 547 |
translated into removing many of the existing inline processors that handled this |
| 548 |
logic: |
| 549 |
|
| 550 |
* `em_strong` |
| 551 |
* `strong` |
| 552 |
* `emphasis` |
| 553 |
* `strong2` |
| 554 |
* `emphasis` |
| 555 |
|
| 556 |
These processors were replaced with two new ones: |
| 557 |
|
| 558 |
* `em_strong` |
| 559 |
* `em_strong2` |
| 560 |
|
| 561 |
The [`legacy_em`](extensions/legacy_em.md) extension was also modified with new, |
| 562 |
refactored logic and simply overrides the `em_strong2` inline processor. |
| 563 |
|
| 564 |
* CodeHilite now always wraps with `<code>` tags |
| 565 |
|
| 566 |
Before, the HTML generated by CodeHilite looked like: |
| 567 |
- `<pre><code>foo = 'bar'</code></pre>` if you **were not** using Pygments. |
| 568 |
- `<pre>foo = 'bar'</pre>` if you **were** using Pygments. |
| 569 |
|
| 570 |
To make the cases more consistent (and adhere to many Markdown specifications and |
| 571 |
HTML code block markup suggestions), CodeHilite will now always additionally wrap |
| 572 |
code with `<code>` tags. See #862 for more details. |
| 573 |
|
| 574 |
This change does not alter the Python-Markdown API, but users relying on the old |
| 575 |
markup will find their output now changed. |
| 576 |
|
| 577 |
Internally, this change relies on the Pygments 2.4, so you must be using at least |
| 578 |
that version to see this effect. Users with earlier Pygments versions will |
| 579 |
continue to see the old behavior. |
| 580 |
|
| 581 |
* `markdown.util.etree` deprecated |
| 582 |
|
| 583 |
Previously, Python-Markdown was using either the `xml.etree.cElementTree` module |
| 584 |
or the `xml.etree.ElementTree` module, based on their availability. In modern |
| 585 |
Python versions, the former is a deprecated alias for the latter. Thus, the |
| 586 |
compatibility layer is deprecated and extensions are advised to use |
| 587 |
`xml.etree.ElementTree` directly. Importing `markdown.util.etree` will raise |
| 588 |
a `DeprecationWarning` beginning in version 3.2 and may be removed in a future |
| 589 |
release. |
| 590 |
|
| 591 |
Therefore, extension developers are encouraged to replace |
| 592 |
`from markdown.util import etree` with |
| 593 |
`import xml.etree.ElementTree as etree` in their code. |
| 594 |
|
| 595 |
### Added |
| 596 |
|
| 597 |
* Some new configuration options have been added to the [toc](extensions/toc.md) |
| 598 |
extension: |
| 599 |
|
| 600 |
* The `anchorlink_class` and `permalink_class` options allow class(es) to be |
| 601 |
assigned to the `anchorlink` and `permalink` respectively. This allows using |
| 602 |
icon fonts from CSS for the links. Therefore, an empty string passed to |
| 603 |
`permalink` now generates an empty `permalink`. Previously no `permalink` |
| 604 |
would have been generated. (#776) |
| 605 |
|
| 606 |
* The `permalink_title` option allows the title attribute of a `permalink` to be |
| 607 |
set to something other than the default English string `Permanent link`. (#877) |
| 608 |
|
| 609 |
* Document thread safety (#812). |
| 610 |
|
| 611 |
* Markdown parsing in HTML has been exposed via a separate extension called |
| 612 |
[`md_in_html`](extensions/md_in_html.md). |
| 613 |
|
| 614 |
* Add support for Python 3.8. |
| 615 |
|
| 616 |
### Fixed |
| 617 |
|
| 618 |
* HTML tag placeholders are no longer included in `.toc_tokens` (#899). |
| 619 |
* Unescape backslash-escaped characters in TOC ids (#864). |
| 620 |
* Refactor bold and italic logic in order to solve complex nesting issues (#792). |
| 621 |
* Always wrap CodeHilite code in `code` tags (#862). |
| 622 |
|
| 623 |
## [3.1.1] - 2019-05-20 |
| 624 |
|
| 625 |
### Fixed |
| 626 |
|
| 627 |
* Fixed import failure in `setup.py` when the source directory is not |
| 628 |
on `sys.path` (#823). |
| 629 |
* Prefer public `packaging` module to pkg_resources' private copy of |
| 630 |
it (#825). |
| 631 |
|
| 632 |
## [3.1.0] - 2019-03-25 |
| 633 |
|
| 634 |
### Changed |
| 635 |
|
| 636 |
* `markdown.version` and `markdown.version_info` deprecated |
| 637 |
|
| 638 |
Historically, version numbers were acquired via the attributes |
| 639 |
`markdown.version` and `markdown.version_info`. As of 3.0, a more standardized |
| 640 |
approach is being followed and versions are acquired via the |
| 641 |
`markdown.__version__` and `markdown.__version_info__` attributes. As of 3.1 |
| 642 |
the legacy attributes will raise a `DeprecationWarning` if they are accessed. In |
| 643 |
a future release the legacy attributes will be removed. |
| 644 |
|
| 645 |
### Added |
| 646 |
|
| 647 |
* A [Contributing Guide](contributing.md) has been added (#732). |
| 648 |
|
| 649 |
* A new configuration option to set the footnote separator has been added. Also, |
| 650 |
the `rel` and `rev` attributes have been removed from footnotes as they are |
| 651 |
not valid in HTML5. The `refs` and `backrefs` classes already exist and |
| 652 |
serve the same purpose (#723). |
| 653 |
|
| 654 |
* A new option for `toc_depth` to set not only the bottom section level, |
| 655 |
but also the top section level. A string consisting of two digits |
| 656 |
separated by a hyphen in between (`"2-5"`), defines the top (`t`) and the |
| 657 |
bottom (`b`) (`<ht>..<hb>`). A single integer still defines the bottom |
| 658 |
section level (`<h1>..<hb>`) only. (#787). |
| 659 |
|
| 660 |
### Fixed |
| 661 |
|
| 662 |
* Update CLI to support PyYAML 5.1. |
| 663 |
* Overlapping raw HTML matches no longer leave placeholders behind (#458). |
| 664 |
* Emphasis patterns now recognize newline characters as whitespace (#783). |
| 665 |
* Version format had been updated to be PEP 440 compliant (#736). |
| 666 |
* Block level elements are defined per instance, not as class attributes |
| 667 |
(#731). |
| 668 |
* Double escaping of block code has been eliminated (#725). |
| 669 |
* Problems with newlines in references has been fixed (#742). |
| 670 |
* Escaped `#` are now handled in header syntax (#762). |
| 671 |
|
| 672 |
## [3.0.1] - 2018-09-28 |
| 673 |
|
| 674 |
### Fixed |
| 675 |
|
| 676 |
* Brought back the `version` and `version_info` variables (#709). |
| 677 |
* Added support for hexadecimal HTML entities (#712). |
| 678 |
|
| 679 |
## [3.0.0] - 2018-09-21 |
| 680 |
|
| 681 |
### Changed |
| 682 |
|
| 683 |
* `enable_attributes` keyword deprecated |
| 684 |
|
| 685 |
The `enable_attributes` keyword is deprecated in version 3.0 and will be |
| 686 |
ignored. Previously the keyword was `True` by default and enabled an |
| 687 |
undocumented way to define attributes on document elements. The feature has been |
| 688 |
removed from version 3.0. As most users did not use the undocumented feature, it |
| 689 |
should not affect most users. For the few who did use the feature, it can be |
| 690 |
enabled by using the [Legacy Attributes](extensions/legacy_attrs.md) |
| 691 |
extension. |
| 692 |
|
| 693 |
* `smart_emphasis` keyword and `smart_strong` extension deprecated |
| 694 |
|
| 695 |
The `smart_emphasis` keyword is deprecated in version 3.0 and will be ignored. |
| 696 |
Previously the keyword was `True` by default and caused the parser to ignore |
| 697 |
middle-word emphasis. Additionally, the optional `smart_strong` extension |
| 698 |
provided the same behavior for strong emphasis. Both of those features are now |
| 699 |
part of the default behavior, and the [Legacy |
| 700 |
Emphasis](extensions/legacy_em.md) extension is available to disable that |
| 701 |
behavior. |
| 702 |
|
| 703 |
* `output_formats` simplified to `html` and `xhtml`. |
| 704 |
|
| 705 |
The `output_formats` keyword now only accepts two options: `html` and `xhtml` |
| 706 |
Note that if `(x)html1`, `(x)html4` or `(x)html5` are passed in, the number is |
| 707 |
stripped and ignored. |
| 708 |
|
| 709 |
* `safe_mode` and `html_replacement_text` keywords deprecated |
| 710 |
|
| 711 |
Both `safe_mode` and the associated `html_replacement_text` keywords are |
| 712 |
deprecated in version 3.0 and will be ignored. The so-called "safe mode" was |
| 713 |
never actually "safe" which has resulted in many people having a false sense of |
| 714 |
security when using it. As an alternative, the developers of Python-Markdown |
| 715 |
recommend that any untrusted content be passed through an HTML sanitizer (like |
| 716 |
[Bleach](https://bleach.readthedocs.io/)) after being converted to HTML by |
| 717 |
markdown. In fact, [Bleach |
| 718 |
Whitelist](https://github.com/yourcelf/bleach-whitelist) provides a curated list |
| 719 |
of tags, attributes, and styles suitable for filtering user-provided HTML using |
| 720 |
bleach. |
| 721 |
|
| 722 |
If your code previously looked like this: |
| 723 |
|
| 724 |
html = markdown.markdown(text, safe_mode=True) |
| 725 |
|
| 726 |
Then it is recommended that you change your code to read something like this: |
| 727 |
|
| 728 |
import bleach |
| 729 |
from bleach_whitelist import markdown_tags, markdown_attrs |
| 730 |
html = bleach.clean(markdown.markdown(text), markdown_tags, markdown_attrs) |
| 731 |
|
| 732 |
If you are not interested in sanitizing untrusted text, but simply desire to |
| 733 |
escape raw HTML, then that can be accomplished through an extension which |
| 734 |
removes HTML parsing: |
| 735 |
|
| 736 |
from markdown.extensions import Extension |
| 737 |
|
| 738 |
class EscapeHtml(Extension): |
| 739 |
def extendMarkdown(self, md): |
| 740 |
md.preprocessors.deregister('html_block') |
| 741 |
md.inlinePatterns.deregister('html') |
| 742 |
|
| 743 |
html = markdown.markdown(text, extensions=[EscapeHtml()]) |
| 744 |
|
| 745 |
As the HTML would not be parsed with the above Extension, then the serializer |
| 746 |
will escape the raw HTML, which is exactly what happened in previous versions |
| 747 |
with `safe_mode="escape"`. |
| 748 |
|
| 749 |
* Positional arguments deprecated |
| 750 |
|
| 751 |
Positional arguments on the `markdown.Markdown()` class are deprecated as are |
| 752 |
all except the `text` argument on the `markdown.markdown()` wrapper function. |
| 753 |
Using positional arguments will raise an error. Only keyword arguments should be |
| 754 |
used. For example, if your code previously looked like this: |
| 755 |
|
| 756 |
html = markdown.markdown(text, [SomeExtension()]) |
| 757 |
|
| 758 |
Then it is recommended that you change it to read something like this: |
| 759 |
|
| 760 |
html = markdown.markdown(text, extensions=[SomeExtension()]) |
| 761 |
|
| 762 |
!!! Note |
| 763 |
This change is being made as a result of deprecating `"safe_mode"` as the |
| 764 |
`safe_mode` argument was one of the positional arguments. When that argument |
| 765 |
is removed, the two arguments following it will no longer be at the correct |
| 766 |
position. It is recommended that you always use keywords when they are |
| 767 |
supported for this reason. |
| 768 |
|
| 769 |
* Extension name behavior has changed |
| 770 |
|
| 771 |
In previous versions of Python-Markdown, the built-in extensions received |
| 772 |
special status and did not require the full path to be provided. Additionally, |
| 773 |
third party extensions whose name started with `"mdx_"` received the same |
| 774 |
special treatment. This is no longer the case. |
| 775 |
|
| 776 |
Support has been added for extensions to define an [entry |
| 777 |
point](extensions/api.md#entry_point). An entry point is a string name which |
| 778 |
can be used to point to an `Extension` class. The built-in extensions now have |
| 779 |
entry points which match the old short names. And any third-party extensions |
| 780 |
which define entry points can now get the same behavior. See the documentation |
| 781 |
for each specific extension to find the assigned name. |
| 782 |
|
| 783 |
If an extension does not define an entry point, then the full path to the |
| 784 |
extension must be used. See the [documentation](reference.md#extensions) for |
| 785 |
a full explanation of the current behavior. |
| 786 |
|
| 787 |
* Extension configuration as part of extension name deprecated |
| 788 |
|
| 789 |
The previously documented method of appending the extension configuration |
| 790 |
options as a string to the extension name is deprecated and will raise an error. |
| 791 |
The [`extension_configs`](reference.md#extension_configs) keyword should be |
| 792 |
used instead. See the [documentation](reference.md#extension_configs) for a |
| 793 |
full explanation of the current behavior. |
| 794 |
|
| 795 |
* HeaderId extension deprecated |
| 796 |
|
| 797 |
The HeaderId Extension is deprecated and will raise an error if specified. Use |
| 798 |
the [Table of Contents](extensions/toc.md) Extension instead, which offers |
| 799 |
most of the features of the HeaderId Extension and more (support for meta data |
| 800 |
is missing). |
| 801 |
|
| 802 |
Extension authors who have been using the `slugify` and `unique` functions |
| 803 |
defined in the HeaderId Extension should note that those functions are now |
| 804 |
defined in the Table of Contents extension and should adjust their import |
| 805 |
statements accordingly (`from markdown.extensions.toc import slugify, unique`). |
| 806 |
|
| 807 |
* Homegrown `OrderedDict` has been replaced with a purpose-built `Registry` |
| 808 |
|
| 809 |
All processors and patterns now get "registered" to a |
| 810 |
[Registry](extensions/api.md#registry). A backwards compatible shim is |
| 811 |
included so that existing simple extensions should continue to work. |
| 812 |
A `DeprecationWarning` will be raised for any code which calls the old API. |
| 813 |
|
| 814 |
* Markdown class instance references. |
| 815 |
|
| 816 |
Previously, instances of the `Markdown` class were represented as any one of |
| 817 |
`md`, `md_instance`, or `markdown`. This inconsistency made it difficult when |
| 818 |
developing extensions, or just maintaining the existing code. Now, all instances |
| 819 |
are consistently represented as `md`. |
| 820 |
|
| 821 |
The old attributes on class instances still exist, but raise a |
| 822 |
`DeprecationWarning` when accessed. Also on classes where the instance was |
| 823 |
optional, the attribute always exists now and is simply `None` if no instance |
| 824 |
was provided (previously the attribute would not exist). |
| 825 |
|
| 826 |
* `markdown.util.isBlockLevel` deprecated |
| 827 |
|
| 828 |
The `markdown.util.isBlockLevel` function is deprecated and will raise a |
| 829 |
`DeprecationWarning`. Instead, extensions should use the `isBlockLevel` method |
| 830 |
of the `Markdown` class instance. Additionally, a list of block level elements |
| 831 |
is defined in the `block_level_elements` attribute of the `Markdown` class which |
| 832 |
extensions can access to alter the list of elements which are treated as block |
| 833 |
level elements. |
| 834 |
|
| 835 |
* `md_globals` keyword deprecated from extension API |
| 836 |
|
| 837 |
Previously, the `extendMarkdown` method of a `markdown.extensions.Extension` |
| 838 |
subclasses accepted an `md_globals` keyword, which contained the value returned |
| 839 |
by Python's `globals()` built-in function. As all of the configuration is now |
| 840 |
held within the `Markdown` class instance, access to the globals is no longer |
| 841 |
necessary and any extensions which expect the keyword will raise a |
| 842 |
`DeprecationWarning`. A future release will raise an error. |
| 843 |
|
| 844 |
* `markdown.version` and `markdown.version_info` deprecated |
| 845 |
|
| 846 |
Historically, version numbers were acquired via the attributes |
| 847 |
`markdown.version` and `markdown.version_info`. Moving forward, a more |
| 848 |
standardized approach is being followed and versions are acquired via the |
| 849 |
`markdown.__version__` and `markdown.__version_info__` attributes. The legacy |
| 850 |
attributes are still available to allow distinguishing versions between the |
| 851 |
legacy Markdown 2.0 series and the Markdown 3.0 series, but in the future the |
| 852 |
legacy attributes will be removed. |
| 853 |
|
| 854 |
* Added new, more flexible `InlineProcessor` class |
| 855 |
|
| 856 |
A new `InlineProcessor` class handles inline processing much better and allows |
| 857 |
for more flexibility. The new `InlineProcessor` classes no longer utilize |
| 858 |
unnecessary pretext and post-text captures. New class can accept the buffer that |
| 859 |
is being worked on and manually process the text without regular expressions and |
| 860 |
return new replacement bounds. This helps us to handle links in a better way and |
| 861 |
handle nested brackets and logic that is too much for regular expression. |
| 862 |
|
| 863 |
### Added |
| 864 |
|
| 865 |
* A new [testing framework](test_tools.md) is included as a part of the |
| 866 |
Markdown library, which can also be used by third party extensions. |
| 867 |
|
| 868 |
* A new `toc_depth` parameter has been added to the |
| 869 |
[Table of Contents Extension](extensions/toc.md). |
| 870 |
|
| 871 |
* A new `toc_tokens` attribute has been added to the Markdown class by the |
| 872 |
[Table of Contents Extension](extensions/toc.md), which contains the raw |
| 873 |
tokens used to build the Table of Contents. Users can use this to build their |
| 874 |
own custom Table of Contents rather than needing to parse the HTML available |
| 875 |
on the `toc` attribute of the Markdown class. |
| 876 |
|
| 877 |
* When the [Table of Contents Extension](extensions/toc.md) is used in |
| 878 |
conjunction with the [Attribute Lists Extension](extensions/attr_list.md) |
| 879 |
and a `data-toc-label` attribute is defined on a header, the content of the |
| 880 |
`data-toc-label` attribute is now used as the content of the Table of Contents |
| 881 |
item for that header. |
| 882 |
|
| 883 |
* Additional CSS class names can be appended to |
| 884 |
[Admonitions](extensions/admonition.md). |
| 885 |
|
| 886 |
# Previous Releases |
| 887 |
|
| 888 |
For information on prior releases, see their changelogs: |
| 889 |
|
| 890 |
* [2.x and earlier](change_log/index.md) |