⚠️ 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
Also add testing for Python 3.11
12.2.0 to 13.0.0A 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.
text_special #276text_special token #280(p) => § replacement in typographer #281silent arg in ParserBlock.tokenize #284skipSpaces/skipChars #271text_special in tree.pretty #282The 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.
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
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.
Thanks to 🎉
Full Changelog: https://github.com/executablebooks/markdown-it-py/compare/v2.1.0...v2.2.0
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.
Rule/Delimiter classes from attrs to dataclass (#211)Token class from attrs to dataclass (#211)NestedTokens and nest_tokensIndexError (#207)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).mdurl and punycode for URL normalisation (thanks to @hukkin!). This port fixes the outstanding CommonMark compliance tests.AttrDict. This is no longer used is core or mdit-py-plugins, instead standard dictionaries are used.__all__ to signal re-exports⬆️ UPGRADE: attrs -> v21 (#165)
This release has no breaking changes (see: https://github.com/python-attrs/attrs/blob/main/CHANGELOG.rst)
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!
RendererProtocol type, for typing renderers (thanks to @hukkinj1)None is no longer allowed as a valid src input for StateBase subclasses‼️ 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:
This is the first beta release of the stable v1.x series.
There are four notable (and breaking) changes:
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.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.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.Ruler.at for pluginsThis release brings Markdown-It-Py inline with Markdown-It v11.0.1 (2020-09-14), applying two fixes:
Thanks to @hukkinj1!
This release provides some improvements to the code base:
🗑 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.
✨ 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
✨ NEW: Add smartquotes, thanks to @tsutsu3.
This extension will convert basic quote marks to their opening and closing variants:
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:
env arg in MarkdownIt.render_Entities.__contains__ fix return dataskipSpacesBack and skipCharsBack methods🧪 TESTS: Add CI for Python 3.9 and PyPy3
✨ 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--- → &mdashmd = 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
👌 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.
✨ NEW: Add anchors_plugin for headers, which can produce:
<h1 id="title-string">Title String <a class="header-anchor" href="#title-string">¶</a></h1>
🐛 Fixed an undefined variable in the reference block.
🐛 Fixed an IndexError in container_plugin, when there is no newline on the closing tag line.
⬆️ UPGRADE: attrs -> v20
This is not breaking, since it only deprecates Python 3.4 (see CHANGELOG.rst)
deflist and dollarmath plugins (see plugins list).containers plugin (see plugins list)