mdit-py-plugins is a collection of plugins for markdown-it-py, the Python Markdown parser. It provides syntax extensions for footnotes, front matter, definition lists, task lists, heading anchors, math (LaTeX), and more. The current version is 0.5.0, and the library is actively maintained with regular releases.
pip install mdit-py-pluginsVerified import paths — ran on the pinned version, not inferred.
Initializes MarkdownIt with 'commonmark' preset and enables the front matter and footnote plugins, then renders a sample Markdown string to HTML.
Upgrade your Python environment to 3.10 or newer.
Review custom plugins or integrations that interact with `markdown-it-py`'s `state` object and update `state.srcCharCode` to `state.src`.
When using `footnote_plugin`, explicitly set `always_match_refs=True` or `False` based on desired behavior: `.use(footnote_plugin, always_match_refs=True)`.
If using attribute plugins, review the new `allowed` option and explicitly configure it if specific attribute handling is required. Check `token.meta["insecure_attrs"]` for attributes that might have been filtered.
Thoroughly test Markdown documents containing `dollarmath` or `amsmath` syntax after upgrading to ensure consistent rendering. Review changelogs for specific math-related fixes.
Import the specific plugin function directly from the `mdit_py_plugins` package and then apply it using `.use()` on your MarkdownIt instance. For example, for footnotes: `from markdown_it import MarkdownIt; from mdit_py_plugins.footnote import footnote_plugin; md = MarkdownIt().use(footnote_plugin)`.
Update `markdown-it-py` to a compatible version, typically by running `pip install --upgrade markdown-it-py` or specifying a version like `markdown-it-py>=3.0.0,<4.0.0` in your project dependencies.
Include a JavaScript library like MathJax or KaTeX in your HTML output and initialize it to process the math elements. For example, link to KaTeX CSS and JS and then run `katex.renderToString` on the math content.
Ensure your front matter adheres to strict YAML syntax and is correctly enclosed by `---` on its own lines, like so: `--- title: My Document author: John Doe --- Your Markdown content here.`