Registry / web-framework / mdx-include

mdx-include

JSON →
library1.4.2pypypi✓ verified 83d ago

mdx-include is a Python Markdown extension that enables the inclusion of local or remote files directly into Markdown documents. It provides advanced features like recursive includes, file content slicing by line/column, caching of included files, and detection of circular inclusions. The current stable version is 1.4.2, with the last update released in July 2022, indicating an irregular release cadence.

pip install mdx-include
INSTALL
IMPORT
SIG · MDX-INCLUDE
M
mdx-include
web-frameworkpythonv1.4.2
Install
1.8s avg
Import
137ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.142s · 18.7MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.8s · import 0.131s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

makeExtension
from mdx_include import makeExtension
import markdown

This quickstart demonstrates how to use `mdx-include` to embed content from one Markdown file (`include_me.md`) into another. The extension processes the `{! file_path !}` syntax to replace it with the target file's content.

import markdown import os # Create a dummy file to include with open('include_me.md', 'w') as f: f.write('This content is from an included file.\n\n- Item 1\n- Item 2') # Markdown content that includes the dummy file markdown_content = """ # Main Document This is the main content. {! include_me.md !} End of document. """ html = markdown.markdown( markdown_content, extensions=['mdx_include'] ) print(html) # Clean up dummy file os.remove('include_me.md')
Debug
Known issues
gotchaThe default include syntax `{! file_path_or_url !}` can conflict with other Python Markdown extensions (e.g., `markdown.extensions.attr_list`).
fix
Customize the include syntax in the extension configuration. Refer to the 'Configuration' section in the documentation for details on changing the syntax pattern.
affects: All versions
gotchaCircular inclusions (e.g., File A includes B, B includes C, C includes A) raise a `CircularIncludeException` by default.
fix
Set `allow_circular_inclusion` to `True` in the extension configuration to allow non-recursive inclusion in such scenarios.
affects: All versions
breakingDo not use `mdx-include` concurrently with the `markdown-include` extension.
fix
Choose one extension for file inclusion; do not enable both `mdx_include` and `markdown_include` in your Markdown extensions list.
affects: All versions
gotchaThe inline `recurs_state` option (`{!+ file!}`) to force recursion is only effective if the global `recursion` configuration option is set to `None`. If `recursion` is `False`, the inline override will not work.
fix
Ensure that the global `recursion` option is `None` if you intend to use the inline `recurs_state` for selective recursive inclusions.
affects: All versions
Upgrade
Version history
1.4.2latest on PyPI · released Jul 26, 2022
Audit
Dependencies
MarkdownrequiredCore dependency as it's a Python Markdown extension.
Agent activity
6 hits · last 30 days
node
6
Resources
mdx-include — pip install mdx-include · libregistry