mdx-include
Python Markdown extension to include local or remote files
What it is and what it does
mdx_include is a Markdown extension that lets you insert the contents of local files or remote URLs directly into your Markdown documents using a simple brace syntax like `{! file.md !}`. It handles recursive inclusion (files can include other files), file slicing by line and column ranges, content caching to avoid re-reading the same file multiple times, and circular inclusion detection. The extension depends on Markdown, rcslice for line/column slicing, and cyclic for circular dependency detection.
The package is motivated by an earlier markdown-include project but adds features like per-inclusion recursion control, indentation preservation, and configurable syntax delimiters. It's designed for documentation workflows where you want to keep content DRY by including shared snippets or examples from source files. Configuration options let you control recursion depth, encoding, caching behavior, and whether to allow local vs. remote includes.
Use it for:
- Include code examples from source files into API documentation, keeping examples in sync with actual code.
- Build modular documentation by including shared sections (e.g., common setup steps) into multiple markdown files.
- Embed test fixtures or sample data files into markdown test reports or guides without manual copy-paste.
- Fetch and embed remote markdown or text files into a local document during build time.
- Slice and include only relevant portions of large files (e.g., a specific function from a source file) using line/column ranges.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Markdown extension that embeds local or remote files into Markdown documents at specified positions, with support for recursive inclusion, file slicing, and content caching.
Yes, if you need file inclusion in Markdown and can tolerate dormant maintenance. The package is stable and has no known vulnerabilities, but it has not been updated since mid-2022. Install it for documentation tooling where you want to embed local or remote files, but do not expect active support or updates for new Markdown or Python versions.
Install
mdx-include on PyPI
pip
pip install mdx-includeuv
uv add mdx-includepoetry
poetry add mdx-includeInstalling mdx-include
Before you install
Low install friction with a pure Python wheel. Maintenance is dormant—last release was 2022-07-26 and no commits since 2024-03-16—so expect no active bug fixes or feature updates, though the package is marked Production/Stable.
License in practice
BSD license is permissive, allowing commercial and private use with minimal restrictions. You may use, modify, and distribute this package freely as long as you include the license notice.
Quickstart
import markdown
text = r"{! file.md !}"
md = markdown.Markdown(extensions=['mdx_include'])
html = md.convert(text)
Verify before relying
- Whether Python 2 support (listed in classifiers) is actually maintained or tested given the dormant status since 2022.
- Current compatibility with recent versions of Markdown and its other dependencies (rcslice, cyclic).
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — Markdown, rcslice, cyclic |
| Maintenance | dormant — 1,480 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 128,762/month — #11,695 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mdx_include-1.4.2-py3-none-any.whl
Keywords: markdown, include, local, remote, file
Tags
More Markup packages
PyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
markdown-it-pyA Python markdown parser that converts markdown…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
et-xmlfileet_xmlfile writes large XML files with minimal…
permissive · top 1,000 on PyPI
tomlkitParses and edits TOML files while preserving…
permissive · top 1,000 on PyPI
docstring-parserParses Python docstrings in ReST, Google,…
permissive · top 1,000 on PyPI
markdown-includeAdds an include directive to Python-Markdown…
copyleft · top 15,000 on PyPI
mkdocs-include-markdown-pluginA MkDocs plugin that includes content from…
permissive · top 15,000 on PyPI
rcsliceSlices lists using a row-column notation with…
permissive · top 15,000 on PyPI
markdownifyConverts HTML to Markdown, with fine-grained…
permissive · top 1,000 on PyPI
markitdownConverts various file formats (PDF, Excel,…
permissive · top 5,000 on PyPI
sphinx_mdincludeSphinx extension that lets you include and…
permissive · top 15,000 on PyPI
mkdocs-include-dir-to-navA MkDocs plugin that automatically expands…
permissive · top 15,000 on PyPI
notion2mdExports Notion pages and blocks to Markdown…
permissive · top 15,000 on PyPI
MarkdownConverts Markdown text to HTML using a Python…
permissive · top 1,000 on PyPI
sphinx-markdown-tablesAdds markdown table support to Sphinx…
copyleft · top 15,000 on PyPI