Registry / testing / pymarkdownlnt

pymarkdownlnt

JSON →
library0.9.39pypypi✓ verified 26d ago

PyMarkdown is a comprehensive Markdown linter that scans files against a robust set of rules to identify potential problems and style issues. It adheres to both GitHub Flavored Markdown and CommonMark specifications, offering both 'scan' mode to detect issues and 'fix' mode to automatically correct certain violations. The project maintains an active and consistent release schedule, typically delivering updates every 1-2 months, with a strong focus on enhancing documentation and continuous improvement.

pip install pymarkdownlnt
INSTALL
IMPORT
SIG · PYMARKDOWNLNT
P
pymarkdownlnt
testingpythonv0.9.39
Install
2.9s avg
Import
655ms
Disk
34MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.9.39 · 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.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.694s · 38.4MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 2.9s · import 0.616s · 36MB
34MB installed
● package 34MB
Code
Verified usage

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

PyMarkdownApi
✓ from pymarkdown.api import PyMarkdownApi
The primary programmatic entry point for scanning and fixing Markdown files.

This quickstart demonstrates how to programmatically use PyMarkdown to scan a Markdown file for issues. It creates a temporary Markdown file, initializes the PyMarkdownApi, scans the file, and prints any detected failures. The fix functionality is commented out but shows how to apply automatic corrections if available.

import os from pymarkdown.api import PyMarkdownApi # Create a dummy Markdown file for scanning markdown_content = """ # Heading 1 This is some text. * Item 1 * Item 2 This is some more text with extra spaces. """ file_path = "example.md" with open(file_path, "w") as f: f.write(markdown_content) # Initialize the API api = PyMarkdownApi() # Scan the file scan_results = api.scan_path(file_path) print(f"Scanning: {file_path}") if scan_results.pragma_errors or scan_results.scan_failures: print("Found issues:") for failure in scan_results.scan_failures: print(f" {failure.log_file}: Line {failure.line_number}, Col {failure.column_number}: {failure.rule_id} - {failure.rule_name} ({failure.rule_description})") else: print("No issues found.") # Optionally, fix the file (if fixable rules triggered) # fix_results = api.fix_path(file_path) # if fix_results.result_file_was_changed: # print(f"File '{file_path}' was fixed.") # with open(file_path, 'r') as f: # print('Fixed content:\n' + f.read()) # else: # print(f"File '{file_path}' did not require fixing.") os.remove(file_path)
pymarkdown --version
Debug
Known issues
breakingThe minimum required Python version was updated from 3.9 to 3.10 in version 0.9.34. [cite: v0.9.34 release notes, 4] Earlier Python versions are no longer supported.
fix
Upgrade your Python environment to 3.10 or later.
affects: >=0.9.34
gotchaIn version 0.9.31, support for JSON5 (allowing comments in JSON configuration files) was enabled by default. [cite: v0.9.31 release notes, 2] If you have existing JSON configuration files that previously relied on comments being ignored or handled differently, this change could alter parsing behavior.
fix
Review your JSON configuration files for compatibility. If you need to revert to strict JSON parsing, use the `--no-json5` command-line argument or configure `no_json5=True`.
affects: >=0.9.31
gotchaWhen using the `--alternate-extensions` command-line argument, the specified extensions completely *replace* the default `.md` extension set. If you wish to lint `.md` files along with other extensions, you must explicitly include `.md` in the list (e.g., `--alternate-extensions=.md,.mdown`).
fix
Always include `.md` in your `--alternate-extensions` list if you still want to lint Markdown files with the default extension.
affects: All versions
gotchaStarting with version 0.9.30, new `disable` and `enable` pragma commands were introduced for document-wide rule control. [cite: v0.9.30 release notes, 8] While older `disable-next-line` and `disable-num-lines` commands still function, migrating to the new commands might be necessary for consistent and comprehensive rule management, especially for blanket disabling/enabling.
fix
Familiarize yourself with the new `disable` and `enable` pragma commands for more flexible rule management. The documentation on pragmas has been updated.
affects: >=0.9.30
gotchaPyMarkdown merges configuration from three sources: built-in defaults, configuration files, and command-line overrides. Later sources (e.g., command line) always override earlier ones. Incorrectly assuming the precedence order can lead to unexpected linting behavior.
fix
Understand the configuration precedence: Built-in defaults < Configuration files (e.g., `config.json`) < Command-line arguments (`--set`). Refer to the 'Advanced Configuration' documentation for details.
affects: All versions
Errors
Common errors & fixes
pymarkdown: command not found
The 'pymarkdown' command-line tool is not found in your system's PATH, typically because the 'pymarkdownlnt' package is not installed or the Python environment where it resides is not active.
fix
Ensure 'pymarkdownlnt' is installed (`pip install pymarkdownlnt`) and verify your virtual environment is activated, or explicitly run it as a Python module: `python -m pymarkdown.main <command>`.
WARNING:pymarkdown.main:Provided path 'some-manner-of-path' does not exist. WARNING:pymarkdown.main:No matching files found.
The 'pymarkdown' linter was invoked with file or directory paths that either do not exist or do not contain any recognizable Markdown files (typically '.md' extension).
fix
Double-check the provided paths for correctness, ensure the files exist and are accessible, and confirm they have the expected Markdown file extensions or use glob patterns like `*.md`.
AttributeError: module 'pymarkdown' has no attribute 'scan'
A user might attempt to directly call 'scan' as a method on the 'pymarkdown' module when trying to use the API, instead of using the dedicated API functions or the command-line interface.
fix
For API usage, import and instantiate the `PyMarkdownApi` class from `pymarkdown.api`, then use its methods like `scan_path`. For command-line scanning, use `pymarkdown scan <path>`.
bash: pymarkdownlnt: command not found
The executable command provided by the `pymarkdownlnt` package is `pymarkdown`, not `pymarkdownlnt`, and it might not be in your system's PATH.
fix
Use `pymarkdown` to invoke the linter. If `pymarkdown` is also not found, ensure pip's script directory is in your system's PATH or run it via `python -m pymarkdown.main scan`.
ERROR: Bad configuration: Invalid data in configuration file: Expecting property name enclosed in double quotes: line X column Y (char Z)
The `.pymarkdown.json` or `.pymarkdown.yaml` configuration file contains a syntax error, such as a missing quote, comma, or incorrect indentation.
fix
Correct the syntax in your configuration file to ensure it is valid JSON or YAML. Using a linter or validator for JSON/YAML can help identify specific errors.
Upgrade
Version history
0.9.39latest on PyPI · released Jul 12, 2026
Audit
Dependencies
application-propertiesrequiredUsed for application configuration, specifically from version 0.9.0 onwards for simplified setup.
columnarrequiredLikely used for structured output or data handling.
setuptoolsrequiredStandard Python package for installation and distribution.
typing-extensionsrequiredProvides backports of new type hints from newer Python versions.
Agent activity
3 hits · last 30 days
node
2
Resources
pymarkdownlnt — pip install pymarkdownlnt · libregistry