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 pymarkdownlntVerified import paths — ran on the pinned version, not inferred.
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.
Upgrade your Python environment to 3.10 or later.
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`.
Always include `.md` in your `--alternate-extensions` list if you still want to lint Markdown files with the default extension.
Familiarize yourself with the new `disable` and `enable` pragma commands for more flexible rule management. The documentation on pragmas has been updated.
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.
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>`.
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`.
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>`.
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`.
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.