Mdformat is an opinionated Markdown formatter that can be used to enforce a consistent style in Markdown files. It functions as both a Unix-style command-line tool and a Python library. The current stable version is 1.0.0, and it features an extensible plugin system to support various Markdown extensions and embedded code formatting. The project maintains an active release cadence, with version 1.0.0 released after several minor versions, indicating ongoing development and maintenance.
pip install mdformatVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `mdformat.text()` to format a Markdown string directly. It also shows how to apply formatting options like numbering ordered lists and setting word wrap width. For file-based formatting, `mdformat.file()` can be used, which modifies the file in place.
Upgrade your Python environment to version 3.10 or later.
Pin the `mdformat` version in your `requirements.txt` or `pyproject.toml` (e.g., `mdformat==1.0.0`).
Install and configure specific `mdformat` plugins (e.g., `pip install mdformat-gfm`) to handle non-CommonMark syntax extensions.
Update custom plugins to conform to the latest plugin API, or check for updated versions of third-party plugins.
If you are confident the formatting is safe, use `mdformat --no-validate` on the CLI or `mdformat.text(..., validate=False)` in the API. Report the issue if it's a bug in `mdformat` or a plugin.
Install a plugin like `mdformat-simple-breaks` if you prefer a different style for thematic breaks.
Install 'mdformat' using pip: 'pip install mdformat'.
Ensure you are using the correct import statement: 'from mdformat import text'.
Install 'mdformat' using pip: 'pip install mdformat', and ensure your PATH includes the directory where pip installs executables.
Provide the 'source' argument when calling 'text': 'mdformat.text(source)'.
Use a valid 'wrap' option: 'keep', 'no', or an integer (e.g., 80).