Python-Markdown Changelog¶
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to the Python Version Specification. See the Contributing Guide for details.
[3.10.0] - 2025-11-03¶
Changed¶
- Officially support Python 3.14 and PyPy 3.11 and drop support for Python 3.9 and PyPy 3.9.
Fixed¶
- Fix an HTML comment parsing case in some Python versions that can cause an infinite loop (#1554).
- Revert the default behavior of
USE_DEFINITION_ORDER(toTrue). The new behavior introduced in 3.9.0 is experimental and results are inconsistent. It should not have been made the default behavior (#1561).
[3.9.0] - 2025-09-04¶
Changed¶
- Footnotes are now ordered by the occurrence of their references in the
document. A new configuration option for the footnotes extension,
USE_DEFINITION_ORDER, has been added to support restoring the previous behavior of ordering footnotes by the occurrence of definitions (#1367).
Fixed¶
- Ensure inline processing iterates through elements in document order (#1546).
- Fix handling of incomplete HTML tags in code spans in Python 3.14 (#1547).
[3.8.2] - 2025-06-19¶
Fixed¶
- Fix
codecsdeprecation in Python 3.14 (#1537). - Fix issue with unclosed comment parsing in Python 3.14 (#1537).
- Fix issue with unclosed declarations in Python 3.14 (#1537).
- Fix issue with unclosed HTML tag
<fooand Python 3.14 (#1537).
[3.8.1] - 2025-06-18¶
Fixed¶
- Ensure incomplete markup declaration in raw HTML doesn’t crash parser (#1534).
- Fixed dropped content in
md_in_html(#1526). - Fixed HTML handling corner case that prevented some content from not being rendered (#1528).
[3.8.0] - 2025-04-09¶
Changed¶
- DRY fix in
abbrextension by introducing methodcreate_element(#1483). - Clean up test directory by removing some redundant tests and port non-redundant cases to the newer test framework.
- Improved performance of the raw HTML post-processor (#1510).
Fixed¶
- Backslash Unescape IDs set via
attr_listontoc(#1493). - Ensure
md_in_htmlprocesses content inside “markdown” blocks as they are parsed outside of “markdown” blocks to keep things more consistent for third-party extensions (#1503). md_in_htmlhandle tags within inline code blocks better (#1075).md_in_htmlfix handling of one-liner block HTML handling (#1074).- Ensure
<center>is treated like a block-level element (#1481). - Ensure that
abbrextension respectsAtomicStringand does not process perceived abbreviations in these strings (#1512). - Ensure
smartyextension correctly renders nested closing quotes (#1514).
[3.7.0] - 2024-08-16¶
Changed¶
-
Refactor
abbrExtensionA new
AbbrTreeprocessorhas been introduced, which replaces the now deprecatedAbbrInlineProcessor. Abbreviation processing now happens after Attribute Lists, avoiding a conflict between the two extensions (#1460).The
AbbrPreprocessorclass has been renamed toAbbrBlockprocessor, which better reflects what it is.AbbrPreprocessorhas been deprecated.A call to
Markdown.reset()now clears all previously defined abbreviations.Abbreviations are now sorted by length before executing
AbbrTreeprocessorto ensure that multi-word abbreviations are implemented even if an abbreviation exists for one of those component words. (#1465)Abbreviations without a definition are now ignored. This avoids applying abbr tags to text without a title value.
Added an optional
glossaryconfiguration option to the abbreviations extension. This provides a simple and efficient way to apply a dictionary of abbreviations to every page.Abbreviations can now be disabled by setting their definition to
""or''. This can be useful when using theglossaryoption.
Fixed¶
- Fixed links to source code on GitHub from the documentation (#1453).
[3.6.0] - 2024-03-14¶
Changed¶
-
Refactor TOC Sanitation
- All postprocessors are now run on heading content.
- Footnote references are now stripped from heading content. Fixes #660.
- A more robust
striptagsis provided to convert headings to plain text. Unlike, themarkupsafeimplementation, HTML entities are not unescaped. - The plain text
name, richhtml, and unescaped rawdata-toc-labelare saved totoc_tokens, allowing users to access the full rich text content of the headings directly fromtoc_tokens. - The value of
data-toc-labelis sanitized separate from heading content before being written toname. This fixes a bug which allowed markup through in certain circumstances. To access the raw unsanitized data, retrieve the value fromtoken['data-toc-label']directly. - An
html.unescapecall is made just prior to callingslugifyso thatslugifyonly operates on Unicode characters. Note thathtml.unescapeis not run onname,html, ordata-toc-label. - The functions
get_nameandstashedHTML2textdefined in thetocextension are both deprecated. Instead, third party extensions should use some combination of the new functionsrun_postprocessors,render_inner_htmlandstriptags.
Fixed¶
- Include
scripts/*.pyin the generated source tarballs (#1430). - Ensure lines after heading in loose list are properly detabbed (#1443).
- Give smarty tree processor higher priority than toc (#1440).
- Permit carets (
^) and square brackets (]) but explicitly exclude backslashes (\) from abbreviations (#1444). - In attribute lists (
attr_list,fenced_code), quoted attribute values are now allowed to contain curly braces (}) (#1414).
[3.5.2] - 2024-01-10¶
Fixed¶
- Fix type annotations for
convertFile- it accepts only bytes-based buffers. Also remove legacy checks from Python 2 (#1400) - Remove legacy import needed only in Python 2 (#1403)
- Fix typo that left the attribute
AdmonitionProcessor.content_indentunset (#1404) - Fix edge-case crash in
InlineProcessorwithAtomicString(#1406). - Fix edge-case crash in
codehilitewith an emptycodetag (#1405). - Improve and expand type annotations in the code base (#1401).
- Fix handling of bogus comments (#1425).
[3.5.1] - 2023-10-31¶
Fixed¶
- Fix a performance problem with HTML extraction where large HTML input could trigger quadratic line counting behavior (#1392).
- Improve and expand type annotations in the code base (#1394).
[3.5.0] - 2023-10-06¶
Added¶
-
Add
permalink_leadingconfiguration option to the toc extension (#1339)A new boolean option
permalink_leadingcontrols the position of the permanent link anchors generated withpermalink. Settingpermalink_leadingtoTruewill cause the links to be inserted at the start of the header, before any other header content. The default behavior forpermalinkis to append permanent links to the header, placing them after all other header content.
Changed¶
- Add support for cPython version 3.12 (and PyPy 3.10) and drop support for Python version 3.7 (#1357).
- Refactor changelog to use the format defined at https://keepachangelog.com/.
- Update the list of empty HTML tags (#1353).
- Add customizable TOC title class to TOC extension (#1293).
- Add API documentation of the code base which is generated by mkdocstrings (#1220).
Fixed¶
- Fix a corner case in admonitions where if an indented code block was provided as the first block, the output would be malformed (#1329).
[3.4.4] - 2023-07-25¶
Fixed¶
- Add a special case for initial
'sto smarty extension (#1305). - Unescape any backslash escaped inline raw HTML (#1358).
- Unescape backslash escaped TOC token names (#1360).
[3.4.3] - 2023-03-23¶
Fixed¶
- Restore console script (#1327).
[3.4.2] - 2023-03-22¶
Fixed¶
- Officially support Python 3.11.
- Improve standalone * and _ parsing (#1300).
- Consider
<html>HTML tag a block-level element (#1309). - Switch from
setup.pytopyproject.toml.
[3.4.1] - 2022-07-15¶
Fixed¶
- Fix an import issue with
importlib.util(#1274).
[3.4.0] - 2022-07-15¶
Changed¶
-
The
tablesextension now uses astyleattribute instead of analignattribute for alignment.The HTML4 spec specifically deprecates the use of the
alignattribute and it does not appear at all in the HTML5 spec. Therefore, by default, the tables extension will now use thestyleattribute (setting just thetext-alignproperty) intdandthblocks.The former behavior is available by setting the
use_align_attributeconfiguration option toTruewhen enabling the extension.For example, to configure the old
alignbehavior:from markdown.extensions.tables import TableExtension markdown.markdown(src, extensions=[TableExtension(use_align_attribute=True)]) -
Backslash unescaping moved to Treeprocessor (#1131).
Unescaping backslash escapes has been moved to a Treeprocessor, which enables proper HTML escaping during serialization. However, it is recognized that various third-party extensions may be calling the old class at
postprocessors.UnescapePostprocessor. Therefore, the old class remains in the code base, but has been deprecated and will be removed in a future release. The new classtreeprocessors.UnescapeTreeprocessorshould be used instead. -
Previously deprecated objects have been removed
Various objects were deprecated in version 3.0 and began raising deprecation warnings (see the version 3.0 release notes for details). Any of those objects which remained in version 3.3 have been removed from the code base in version 3.4 and will now raise errors. The relevant objects are listed below.
Deprecated Object Replacement Object markdown.versionmarkdown.__version__markdown.version_infomarkdown.__version_info__markdown.util.etreexml.etree.ElementTreemarkdown.util.string_typestrmarkdown.util.text_typestrmarkdown.util.int2strchrmarkdown.util.iterrangerangemarkdown.util.isBlockLevelmarkdown.Markdown().is_block_levelmarkdown.util.Processor().markdownmarkdown.util.Processor().mdmarkdown.util.Registry().__setitem__markdown.util.Registry().registermarkdown.util.Registry().__delitem__markdown.util.Registry().deregistermarkdown.util.Registry().addmarkdown.util.Registry().registerIn addition, the
md_globalsparameter ofMarkdown.extensions.Extension.extendMarkdown()is no longer recognized as a valid parameter and will raise an error if provided.
Added¶
-
Some new configuration options have been added to the footnotes extension (#1218):
-
Small refactor of the
BACKLINK_TITLEoption; The use offormat()instead of “old”%dformatter allows one to specify text without the need to have the number of the footnote in it (like footnotes on Wikipedia for example). The modification is backward compatible so no configuration change is required. -
Addition of a new option
SUPERSCRIPT_TEXTthat allows one to specify a custom placeholder for the footnote itself in the text. Ex:[{}]will give<sup>[1]</sup>,({})will give<sup>(1)</sup>, or by default, the current behavior:<sup>1</sup>.
-
-
The Table of Contents extension now accepts a
toc_classparameter which can be used to set the CSS class(es) on the<div>that contains the Table of Contents (#1224). -
The CodeHilite extension now supports a
pygments_formatteroption that can be set to a custom formatter class (#1187).- If
pygments_formatteris set to a string (ex:'html'), Pygments’ default formatter by that name is used. - If
pygments_formatteris set to a formatter class (or any callable which returns a formatter instance), then an instance of that class is used.
The formatter class is now passed an additional option,
lang_str, to denote the language of the code block (#1258). While Pygments’ built-in formatters will ignore the option, a custom formatter assigned to thepygments_formatteroption can make use of thelang_strto include the code block’s language in the output. - If
Fixed¶
- Extension entry-points are only loaded if needed (#1216).
- Added additional checks to the
<pre><code>handling ofPrettifyTreeprocessor(#1261, #1263). - Fix XML deprecation warnings.
[3.3.7] - 2022-05-05¶
Fixed¶
- Disallow square brackets in reference link ids (#1209).
- Retain configured
pygments_styleafter first code block (#1240). - Ensure fenced code attributes are properly escaped (#1247).
[3.3.6] - 2021-11-17¶
Fixed¶
[3.3.5] - 2021-11-16¶
Fixed¶
- Make the
slugify_unicodefunction not remove diacritical marks (#1118). - Fix
[toc]detection when used withnl2brextension (#1160). - Re-use compiled regex for block level checks (#1169).
- Don’t process shebangs in fenced code blocks when using CodeHilite (#1156).
- Improve email address validation for Automatic Links (#1165).
- Ensure
<summary>tags are parsed correctly (#1079). - Support Python 3.10 (#1124).
[3.3.4] - 2021-02-24¶
Fixed¶
- Properly parse unclosed tags in code spans (#1066).
- Properly parse processing instructions in md_in_html (#1070).
- Properly parse code spans in md_in_html (#1069).
- Preserve text immediately before an admonition (#1092).
- Simplified regex for HTML placeholders (#928) addressing (#932).
- Ensure
permalinksandanchorlinksare not restricted bytoc_depth(#1107). - Fix corner cases with lists under admonitions (#1102).
[3.3.3] - 2020-10-25¶
Fixed¶
- Unify all block-level tags (#1047).
- Fix issue where some empty elements would have text rendered as
Nonewhen usingmd_in_html(#1049). - Avoid catastrophic backtracking in
hrregex (#1055). - Fix
hrHTML handling (#1053).
[3.3.2] - 2020-10-19¶
Fixed¶
- Properly parse inline HTML in md_in_html (#1040 & #1045).
- Avoid crashing when md_in_html fails (#1040).
[3.3.1] - 2020-10-12¶
Fixed¶
- Correctly parse raw
scriptandstyletags (#1036). - Ensure consistent class handling by
fenced_codeandcodehilite(#1032).
[3.3.0] - 2020-10-06¶
Changed¶
-
The prefix
language-is now prepended to all language classes by default on code blocks.The HTML5 spec recommends that the class defining the language of a code block be prefixed with
language-. Therefore, by default, both the fenced_code and codehilite extensions now prepend the prefix when code highlighting is disabled.If you have previously been including the prefix manually in your fenced code blocks, then you will not want a second instance of the prefix. Similarly, if you are using a third party syntax highlighting tool which does not recognize the prefix, or requires a different prefix, then you will want to redefine the prefix globally using the
lang_prefixconfiguration option of either thefenced_codeorcodehiliteextensions.For example, to configure
fenced_codeto not apply any prefix (the previous behavior), set the option to an empty string:from markdown.extensions.fenced_code import FencedCodeExtension markdown.markdown(src, extensions=[FencedCodeExtension(lang_prefix='')])Note
When code highlighting is enabled, the output from Pygments is used unaltered. Currently, Pygments does not provide an option to include the language class in the output, let alone prefix it. Therefore, any language prefix is only applied when syntax highlighting is disabled.
-
Attribute Lists are more strict (#898).
Empty curly braces are now completely ignored by the Attribute List extension. Previously, the extension would recognize them as attribute lists and remove them from the document. Therefore, it is no longer necessary to backslash escape a set of curly braces which are empty or only contain whitespace.
Despite not being documented, previously an attribute list could be defined anywhere within a table cell and get applied to the cell (
<td>element). Now the attribute list must be defined at the end of the cell content and must be separated from the rest of the content by at least one space. This makes it easy to differentiate between attribute lists defined on inline elements within a cell and the attribute list for the cell itself. It is also more consistent with how attribute lists are defined on other types of elements.The extension has also added support for defining attribute lists on table header cells (
<th>elements) in the same manner as data cells (<td>elements).In addition, the documentation for the extensions received an overhaul. The features (#987) and limitations (#965) of the extension are now fully documented.
Added¶
-
All Pygments’ options are now available for syntax highlighting (#816).
- The Codehilite extension now accepts any options which Pygments supports as global configuration settings on the extension.
- Fenced Code Blocks will accept any of the same options on individual code blocks.
- Any of the previously supported aliases to Pygments’ options continue to be supported at this time. However, it is recommended that the Pygments option names be used directly to ensure continued compatibility in the future.
-
Fenced Code Blocks now work with Attribute Lists when syntax highlighting is disabled. Any random HTML attribute can be defined and set on the
<code>tag of fenced code blocks when theattr_listextension is enabled (#816). -
The HTML parser has been completely replaced. The new HTML parser is built on Python’s
html.parser.HTMLParser, which alleviates various bugs and simplify maintenance of the code (#803, #830). -
The Markdown in HTML extension has been rebuilt on the new HTML Parser, which drastically simplifies it. Note that raw HTML elements with a
markdownattribute defined are now converted to ElementTree Elements and are rendered by the serializer. Various bugs have been fixed (#803, #595, #780, and #1012). -
Link reference parsing, abbreviation reference parsing and footnote reference parsing has all been moved from
preprocessorstoblockprocessors, which allows them to be nested within other block level elements. Specifically, this change was necessary to maintain the current behavior in the rebuilt Markdown in HTML extension. A few random edge-case bugs (see the included tests) were resolved in the process (#803). -
An alternate function
markdown.extensions.headerid.slugify_unicodehas been included with the Table of Contents extension which supports Unicode characters in table of contents slugs. The oldmarkdown.extensions.headerid.slugifymethod which removes non-ASCII characters remains the default. Import and passmarkdown.extensions.headerid.slugify_unicodeto theslugifyconfiguration option to use the new behavior. -
Support was added for Python 3.9 and dropped for Python 3.5.
Fixed¶
- Document how to pass configuration options to Extra (#1019).
- Fix HR which follows strong em (#897).
- Support short reference image links (#894).
- Avoid a
RecursionErrorfrom deeply nested blockquotes (#799). - Fix issues with complex emphasis (#979).
- Fix unescaping of HTML characters
<>in CodeHilite (#990). - Fix complex scenarios involving lists and admonitions (#1004).
- Fix complex scenarios with nested ordered and unordered lists in a definition list (#918).
[3.2.2] - 2020-05-08¶
Fixed¶
- Add
checklinkstox environment to ensure all links in documentation are good. - Refactor extension API documentation (#729).
- Load entry_points (for extensions) only once using
importlib.metadata. - Do not double escape entities in TOC.
- Correctly report if an extension raises a
TypeError(#939). - Raise a
KeyErrorwhen attempting to delete a nonexistent key from the extension registry (#939). - Remove import of
packaging(orpkg_resourcesfallback) entirely. - Remove
setuptoolsas a run-time dependency (install_required).
[3.2.1] - 2020-02-12¶
Fixed¶
- The
nameproperty intoc_tokensfrom the TOC extension now escapes HTML special characters (<,>, and&).
[3.2.0] - 2020-02-07¶
Changed¶
-
Drop support for Python 2.7
Python 2.7 reaches end-of-life on 2020-01-01 and Python-Markdown 3.2 has dropped support for it. Please upgrade to Python 3, or use Python-Markdown 3.1.
-
emandstronginline processor changesIn order to fix issue #792,
em/stronginline processors were refactored. This translated into removing many of the existing inline processors that handled this logic:em_strongstrongemphasisstrong2emphasis
These processors were replaced with two new ones:
em_strongem_strong2
The
legacy_emextension was also modified with new, refactored logic and simply overrides theem_strong2inline processor. -
CodeHilite now always wraps with
<code>tagsBefore, the HTML generated by CodeHilite looked like: -
<pre><code>foo = 'bar'</code></pre>if you were not using Pygments. -<pre>foo = 'bar'</pre>if you were using Pygments.To make the cases more consistent (and adhere to many Markdown specifications and HTML code block markup suggestions), CodeHilite will now always additionally wrap code with
<code>tags. See #862 for more details.This change does not alter the Python-Markdown API, but users relying on the old markup will find their output now changed.
Internally, this change relies on the Pygments 2.4, so you must be using at least that version to see this effect. Users with earlier Pygments versions will continue to see the old behavior.
-
markdown.util.etreedeprecatedPreviously, Python-Markdown was using either the
xml.etree.cElementTreemodule or thexml.etree.ElementTreemodule, based on their availability. In modern Python versions, the former is a deprecated alias for the latter. Thus, the compatibility layer is deprecated and extensions are advised to usexml.etree.ElementTreedirectly. Importingmarkdown.util.etreewill raise aDeprecationWarningbeginning in version 3.2 and may be removed in a future release.Therefore, extension developers are encouraged to replace
from markdown.util import etreewithimport xml.etree.ElementTree as etreein their code.
Added¶
-
Some new configuration options have been added to the toc extension:
-
The
anchorlink_classandpermalink_classoptions allow class(es) to be assigned to theanchorlinkandpermalinkrespectively. This allows using icon fonts from CSS for the links. Therefore, an empty string passed topermalinknow generates an emptypermalink. Previously nopermalinkwould have been generated. (#776) -
The
permalink_titleoption allows the title attribute of apermalinkto be set to something other than the default English stringPermanent link. (#877)
-
-
Document thread safety (#812).
-
Markdown parsing in HTML has been exposed via a separate extension called
md_in_html. -
Add support for Python 3.8.
Fixed¶
- HTML tag placeholders are no longer included in
.toc_tokens(#899). - Unescape backslash-escaped characters in TOC ids (#864).
- Refactor bold and italic logic in order to solve complex nesting issues (#792).
- Always wrap CodeHilite code in
codetags (#862).
[3.1.1] - 2019-05-20¶
Fixed¶
- Fixed import failure in
setup.pywhen the source directory is not onsys.path(#823). - Prefer public
packagingmodule to pkg_resources’ private copy of it (#825).
[3.1.0] - 2019-03-25¶
Changed¶
-
markdown.versionandmarkdown.version_infodeprecatedHistorically, version numbers were acquired via the attributes
markdown.versionandmarkdown.version_info. As of 3.0, a more standardized approach is being followed and versions are acquired via themarkdown.__version__andmarkdown.__version_info__attributes. As of 3.1 the legacy attributes will raise aDeprecationWarningif they are accessed. In a future release the legacy attributes will be removed.
Added¶
-
A Contributing Guide has been added (#732).
-
A new configuration option to set the footnote separator has been added. Also, the
relandrevattributes have been removed from footnotes as they are not valid in HTML5. Therefsandbackrefsclasses already exist and serve the same purpose (#723). -
A new option for
toc_depthto set not only the bottom section level, but also the top section level. A string consisting of two digits separated by a hyphen in between ("2-5"), defines the top (t) and the bottom (b) (<ht>..<hb>). A single integer still defines the bottom section level (<h1>..<hb>) only. (#787).
Fixed¶
- Update CLI to support PyYAML 5.1.
- Overlapping raw HTML matches no longer leave placeholders behind (#458).
- Emphasis patterns now recognize newline characters as whitespace (#783).
- Version format had been updated to be PEP 440 compliant (#736).
- Block level elements are defined per instance, not as class attributes (#731).
- Double escaping of block code has been eliminated (#725).
- Problems with newlines in references has been fixed (#742).
- Escaped
#are now handled in header syntax (#762).
[3.0.1] - 2018-09-28¶
Fixed¶
- Brought back the
versionandversion_infovariables (#709). - Added support for hexadecimal HTML entities (#712).
[3.0.0] - 2018-09-21¶
Changed¶
-
enable_attributeskeyword deprecatedThe
enable_attributeskeyword is deprecated in version 3.0 and will be ignored. Previously the keyword wasTrueby default and enabled an undocumented way to define attributes on document elements. The feature has been removed from version 3.0. As most users did not use the undocumented feature, it should not affect most users. For the few who did use the feature, it can be enabled by using the Legacy Attributes extension. -
smart_emphasiskeyword andsmart_strongextension deprecatedThe
smart_emphasiskeyword is deprecated in version 3.0 and will be ignored. Previously the keyword wasTrueby default and caused the parser to ignore middle-word emphasis. Additionally, the optionalsmart_strongextension provided the same behavior for strong emphasis. Both of those features are now part of the default behavior, and the Legacy Emphasis extension is available to disable that behavior. -
output_formatssimplified tohtmlandxhtml.The
output_formatskeyword now only accepts two options:htmlandxhtmlNote that if(x)html1,(x)html4or(x)html5are passed in, the number is stripped and ignored. -
safe_modeandhtml_replacement_textkeywords deprecatedBoth
safe_modeand the associatedhtml_replacement_textkeywords are deprecated in version 3.0 and will be ignored. The so-called “safe mode” was never actually “safe” which has resulted in many people having a false sense of security when using it. As an alternative, the developers of Python-Markdown recommend that any untrusted content be passed through an HTML sanitizer (like Bleach) after being converted to HTML by markdown. In fact, Bleach Whitelist provides a curated list of tags, attributes, and styles suitable for filtering user-provided HTML using bleach.If your code previously looked like this:
html = markdown.markdown(text, safe_mode=True)Then it is recommended that you change your code to read something like this:
import bleach from bleach_whitelist import markdown_tags, markdown_attrs html = bleach.clean(markdown.markdown(text), markdown_tags, markdown_attrs)If you are not interested in sanitizing untrusted text, but simply desire to escape raw HTML, then that can be accomplished through an extension which removes HTML parsing:
from markdown.extensions import Extension class EscapeHtml(Extension): def extendMarkdown(self, md): md.preprocessors.deregister('html_block') md.inlinePatterns.deregister('html') html = markdown.markdown(text, extensions=[EscapeHtml()])As the HTML would not be parsed with the above Extension, then the serializer will escape the raw HTML, which is exactly what happened in previous versions with
safe_mode="escape". -
Positional arguments deprecated
Positional arguments on the
markdown.Markdown()class are deprecated as are all except thetextargument on themarkdown.markdown()wrapper function. Using positional arguments will raise an error. Only keyword arguments should be used. For example, if your code previously looked like this:html = markdown.markdown(text, [SomeExtension()])Then it is recommended that you change it to read something like this:
html = markdown.markdown(text, extensions=[SomeExtension()])Note
This change is being made as a result of deprecating
"safe_mode"as thesafe_modeargument was one of the positional arguments. When that argument is removed, the two arguments following it will no longer be at the correct position. It is recommended that you always use keywords when they are supported for this reason. -
Extension name behavior has changed
In previous versions of Python-Markdown, the built-in extensions received special status and did not require the full path to be provided. Additionally, third party extensions whose name started with
"mdx_"received the same special treatment. This is no longer the case.Support has been added for extensions to define an entry point. An entry point is a string name which can be used to point to an
Extensionclass. The built-in extensions now have entry points which match the old short names. And any third-party extensions which define entry points can now get the same behavior. See the documentation for each specific extension to find the assigned name.If an extension does not define an entry point, then the full path to the extension must be used. See the documentation for a full explanation of the current behavior.
-
Extension configuration as part of extension name deprecated
The previously documented method of appending the extension configuration options as a string to the extension name is deprecated and will raise an error. The
extension_configskeyword should be used instead. See the documentation for a full explanation of the current behavior. -
HeaderId extension deprecated
The HeaderId Extension is deprecated and will raise an error if specified. Use the Table of Contents Extension instead, which offers most of the features of the HeaderId Extension and more (support for meta data is missing).
Extension authors who have been using the
slugifyanduniquefunctions defined in the HeaderId Extension should note that those functions are now defined in the Table of Contents extension and should adjust their import statements accordingly (from markdown.extensions.toc import slugify, unique). -
Homegrown
OrderedDicthas been replaced with a purpose-builtRegistryAll processors and patterns now get “registered” to a Registry. A backwards compatible shim is included so that existing simple extensions should continue to work. A
DeprecationWarningwill be raised for any code which calls the old API. -
Markdown class instance references.
Previously, instances of the
Markdownclass were represented as any one ofmd,md_instance, ormarkdown. This inconsistency made it difficult when developing extensions, or just maintaining the existing code. Now, all instances are consistently represented asmd.The old attributes on class instances still exist, but raise a
DeprecationWarningwhen accessed. Also on classes where the instance was optional, the attribute always exists now and is simplyNoneif no instance was provided (previously the attribute would not exist). -
markdown.util.isBlockLeveldeprecatedThe
markdown.util.isBlockLevelfunction is deprecated and will raise aDeprecationWarning. Instead, extensions should use theisBlockLevelmethod of theMarkdownclass instance. Additionally, a list of block level elements is defined in theblock_level_elementsattribute of theMarkdownclass which extensions can access to alter the list of elements which are treated as block level elements. -
md_globalskeyword deprecated from extension APIPreviously, the
extendMarkdownmethod of amarkdown.extensions.Extensionsubclasses accepted anmd_globalskeyword, which contained the value returned by Python’sglobals()built-in function. As all of the configuration is now held within theMarkdownclass instance, access to the globals is no longer necessary and any extensions which expect the keyword will raise aDeprecationWarning. A future release will raise an error. -
markdown.versionandmarkdown.version_infodeprecatedHistorically, version numbers were acquired via the attributes
markdown.versionandmarkdown.version_info. Moving forward, a more standardized approach is being followed and versions are acquired via themarkdown.__version__andmarkdown.__version_info__attributes. The legacy attributes are still available to allow distinguishing versions between the legacy Markdown 2.0 series and the Markdown 3.0 series, but in the future the legacy attributes will be removed. -
Added new, more flexible
InlineProcessorclassA new
InlineProcessorclass handles inline processing much better and allows for more flexibility. The newInlineProcessorclasses no longer utilize unnecessary pretext and post-text captures. New class can accept the buffer that is being worked on and manually process the text without regular expressions and return new replacement bounds. This helps us to handle links in a better way and handle nested brackets and logic that is too much for regular expression.
Added¶
-
A new testing framework is included as a part of the Markdown library, which can also be used by third party extensions.
-
A new
toc_depthparameter has been added to the Table of Contents Extension. -
A new
toc_tokensattribute has been added to the Markdown class by the Table of Contents Extension, which contains the raw tokens used to build the Table of Contents. Users can use this to build their own custom Table of Contents rather than needing to parse the HTML available on thetocattribute of the Markdown class. -
When the Table of Contents Extension is used in conjunction with the Attribute Lists Extension and a
data-toc-labelattribute is defined on a header, the content of thedata-toc-labelattribute is now used as the content of the Table of Contents item for that header. -
Additional CSS class names can be appended to Admonitions.
Previous Releases¶
For information on prior releases, see their changelogs:

