{"library":"mdformat-mkdocs","title":"mdformat-mkdocs Plugin for MkDocs Formatting","description":"mdformat-mkdocs is an mdformat plugin designed to format Markdown files specifically tailored for MkDocs and Material for MkDocs. It handles features like blockquote directives (admonitions) and other MkDocs-specific syntax, ensuring consistent styling when used with the `mdformat` CLI tool. It is actively maintained and generally follows the release cadence of its host library, `mdformat`, releasing updates as needed to maintain compatibility and add features.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install mdformat-mkdocs"],"cli":{"name":"mdformat","version":"mdformat 1.0.0 (mdformat_mkdocs 5.1.4, mdformat-gfm 1.0.0)"}},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"# 1. Install mdformat-mkdocs\npip install mdformat-mkdocs\n\n# 2. Create an example Markdown file (e.g., 'docs/index.md')\nwith open('docs/index.md', 'w') as f:\n    f.write('## My Doc\\n\\n!!! note \"Hello\"\\n    This is a note.\\n\\n<p>Some HTML comment</p>\\n')\n\n# 3. Format the file using mdformat with the mkdocs plugin\n#    (Note: The 'docs' directory must exist for the file to be created)\nimport os\nif not os.path.exists('docs'):\n    os.makedirs('docs')\n\n# Using a subprocess call as mdformat is primarily a CLI tool\nimport subprocess\nresult = subprocess.run(['mdformat', '--plugins', 'mkdocs', 'docs/index.md'], capture_output=True, text=True)\n\n# Print the formatted content (mdformat modifies the file in place by default)\nwith open('docs/index.md', 'r') as f:\n    formatted_content = f.read()\n\nprint(\"--- Original (before format) ---\")\nprint(\"## My Doc\\n\\n!!! note \\\"Hello\\\"\\n    This is a note.\\n\\n<p>Some HTML comment</p>\\n\")\nprint(\"\\n--- Formatted Content ---\")\nprint(formatted_content)\n\n# Expected output for the admonition and blank line removal\n# Note: mdformat applies its own default styles too\n# Expected: \n# ## My Doc\n#\n# !!! note \"Hello\"\n#     This is a note.\n# <!-- Some HTML comment -->","lang":"python","description":"This quickstart demonstrates how to install `mdformat-mkdocs` and use it to format a Markdown file with MkDocs-specific syntax, such as admonitions. The `mdformat` command-line tool is used, and the `--plugins mkdocs` argument explicitly enables the plugin. The example shows how to format a file and then read its content, as `mdformat` typically modifies files in-place.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}