{"id":4708,"library":"pymarkdownlnt","title":"PyMarkdown Linter","description":"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.","status":"active","version":"0.9.36","language":"en","source_language":"en","source_url":"https://github.com/jackdewinter/pymarkdown","tags":["linter","markdown","github-flavored-markdown","commonmark","static-analysis","code-quality"],"install":[{"cmd":"pip install pymarkdownlnt","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Used for application configuration, specifically from version 0.9.0 onwards for simplified setup.","package":"application-properties","optional":false},{"reason":"Likely used for structured output or data handling.","package":"columnar","optional":false},{"reason":"Standard Python package for installation and distribution.","package":"setuptools","optional":false},{"reason":"Provides backports of new type hints from newer Python versions.","package":"typing-extensions","optional":false}],"imports":[{"note":"The primary programmatic entry point for scanning and fixing Markdown files.","symbol":"PyMarkdownApi","correct":"from pymarkdown.api import PyMarkdownApi"}],"quickstart":{"code":"import os\nfrom pymarkdown.api import PyMarkdownApi\n\n# Create a dummy Markdown file for scanning\nmarkdown_content = \"\"\"\n# Heading 1\n\nThis is some text.\n\n  * Item 1\n  * Item 2\n\nThis is some more text with  extra  spaces.\n\"\"\"\nfile_path = \"example.md\"\nwith open(file_path, \"w\") as f:\n    f.write(markdown_content)\n\n# Initialize the API\napi = PyMarkdownApi()\n\n# Scan the file\nscan_results = api.scan_path(file_path)\n\nprint(f\"Scanning: {file_path}\")\nif scan_results.pragma_errors or scan_results.scan_failures:\n    print(\"Found issues:\")\n    for failure in scan_results.scan_failures:\n        print(f\"  {failure.log_file}: Line {failure.line_number}, Col {failure.column_number}: {failure.rule_id} - {failure.rule_name} ({failure.rule_description})\")\nelse:\n    print(\"No issues found.\")\n\n# Optionally, fix the file (if fixable rules triggered)\n# fix_results = api.fix_path(file_path)\n# if fix_results.result_file_was_changed:\n#     print(f\"File '{file_path}' was fixed.\")\n#     with open(file_path, 'r') as f:\n#         print('Fixed content:\\n' + f.read())\n# else:\n#     print(f\"File '{file_path}' did not require fixing.\")\n\nos.remove(file_path)\n","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or later.","message":"The 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.","severity":"breaking","affected_versions":">=0.9.34"},{"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`.","message":"In 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.","severity":"gotcha","affected_versions":">=0.9.31"},{"fix":"Always include `.md` in your `--alternate-extensions` list if you still want to lint Markdown files with the default extension.","message":"When 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`).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Familiarize yourself with the new `disable` and `enable` pragma commands for more flexible rule management. The documentation on pragmas has been updated.","message":"Starting 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.","severity":"gotcha","affected_versions":">=0.9.30"},{"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.","message":"PyMarkdown 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}