--- id: mdformat-black version: "0.1.1" license: MIT license_treatment: permissive maintenance: aging --- # mdformat-black — Mdformat plugin to Blacken Python code blocks License: permissive · Maintenance: aging · Downloads: 114.4K/mo ## What it is and what it does mdformat-black is a plugin that extends mdformat to apply Black's Python code formatting rules to Python code blocks within Markdown files. When installed, mdformat automatically recognizes and formats Python code blocks using Black's conventions—converting quote styles, enforcing line length, and applying other Black rules—while leaving the rest of your Markdown untouched. The plugin works both from the command line (automatically after install) and programmatically via mdformat's Python API (where you must explicitly enable it by passing `codeformatters={"python"}` to mdformat.text()). It requires Python >=3.6,<4.0 and depends on mdformat and black as runtime dependencies. Use it for: - Automatically format Python code examples in technical documentation to match your project's Black style. - Ensure consistency between code snippets in README files and your actual codebase formatting. - Integrate Python code block formatting into a Markdown linting or CI pipeline alongside mdformat. - Format Python code blocks in blog posts or tutorials written in Markdown without manual editing. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A plugin for mdformat that automatically formats Python code blocks in Markdown files using Black's code style rules. Yes, if you use mdformat and want Python code blocks in your Markdown to follow Black's style. The low install friction, permissive license, and lack of known vulnerabilities make it straightforward. However, the aging maintenance status (last release 2020-09-24) means you should verify compatibility with your current Black and mdformat versions before relying on it in production workflows. ## Install pip install mdformat-black uv add mdformat-black poetry add mdformat-black ## Installing mdformat-black Before you install: Low install friction with just two runtime dependencies. The package is aging—last release was 2020-09-24 and last commit 2025-03-09—but remains unarchived. License in practice: MIT license is permissive; you can use, modify, and distribute freely with minimal restrictions. Quickstart: pip install mdformat-black import mdformat unformatted = "```python\n'''black converts quotes'''\n```\n" formatted = mdformat.text(unformatted, codeformatters={"python"}) assert formatted == '```python\n"""black converts quotes"""\n```\n' Requires mdformat and black to be installed; Python >=3.6,<4.0 Verify before relying: - Whether the package works reliably with recent versions of black and mdformat beyond classifier claims. - Whether there are known incompatibilities with Python 3.9+ despite the 'supports_current' designation. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 114.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags markdown python code formatter, mdformat black plugin, format python in markdown, black code blocks markdown, markdown code formatting, python block formatter, mdformat plugin, markdown-formatting, code-style-enforcement [View on SkillFed](https://skillfed.io/packages/mdformat-black) · [View on PyPI](https://pypi.org/project/mdformat-black/)