skillfed

mdformat-ruff

Mdformat plugin to ruffen Python code blocks

mdformat-ruff v0.1.3 122.0K downloads/30d#11,963 on PyPI28
Permissive license MIT AGING released

What it is and what it does

mdformat-ruff is a plugin for mdformat that applies ruff formatting rules to Python code blocks embedded in Markdown files. When installed, it automatically enables ruff as the code formatter for Python blocks when you run mdformat from the command line, or you can explicitly enable it via the mdformat Python API by passing python to the codeformatters parameter.

The plugin depends only on ruff and integrates into mdformat's plugin architecture. It works with Python 3.7 through 3.12 and is commonly used in documentation workflows and pre-commit hooks to ensure Python code examples in Markdown stay consistently formatted.

Use it for:

  • Format Python code examples in project README and documentation files to match your ruff configuration.
  • Enforce consistent code style in Markdown-based documentation as part of a pre-commit hook workflow.
  • Automatically convert Python string quotes in code blocks when ruff is configured to do so.
  • Maintain formatting consistency between Python code blocks in Markdown and the main codebase during CI/CD checks.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Integrates ruff code formatting into mdformat to automatically format Python code blocks within Markdown files.

Yes, if you use mdformat for Markdown formatting and want Python code blocks formatted by ruff. Install friction is minimal and the plugin integrates transparently. The aging maintenance status is a minor concern—no recent updates—but the package remains functional and unarchived with no known vulnerabilities. Suitable for documentation workflows where ruff is already your Python formatter.

Install

mdformat-ruff on PyPI

pip

pip install mdformat-ruff

uv

uv add mdformat-ruff

poetry

poetry add mdformat-ruff

Installing mdformat-ruff

Before you install

Low friction install with a single runtime dependency (ruff). Maintenance status is aging—last release was over a year ago, though the repository remains unarchived.

License in practice

MIT license permits unrestricted use, modification, and distribution with minimal obligations.

Quickstart

pip install mdformat-ruff

import mdformat

unformatted = "```python\n'''ruff converts quotes'''\n```\n"
formatted = mdformat.text(unformatted, codeformatters={"python"})
assert formatted == '```python\n"""ruff converts quotes"""\n```\n'

Verify before relying

  • Whether ruff version pinning (e.g., ruff==22.1.0) remains necessary for current versions.
  • Compatibility with recent mdformat releases and how often updates are planned.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.7,<4.0)
Install friction low — pure-Python wheel
Runtime dependencies 1 — ruff
Maintenance aging — 915 days since the last release
Last repo commit
First released
Downloads 122,041/month — #11,963 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: mdformat_ruff-0.1.3-py3-none-any.whl

Keywords: mdformat, markdown, commonmark, formatter

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: DocumentationTopic :: Text Processing :: MarkupTyping :: Typed

Tags

markdown python code formattermdformat plugin ruffformat python in markdownmarkdown code block formattingruff markdown integration
markdown-formattingcode-block-linting

More Markup packages