MD Formatter
Format and lint markdown files with consistent conventions.
Quick Start
Run the formatter script on a file:
python3 scripts/format_md.py <file.md>
The script performs:
- Heading normalization: Promote headings to start at
#, ensure no level skips (e.g.,#→###), convert===/---underlined headings to#style. - Link formatting: Convert
<https://url>to[url](https://url)when appropriate, standardize bare URLs. - Trailing whitespace: Remove it.
- Bold/italic consistency: Prefer
**bold**over__bold__,*italic*over_italic_. - Empty lines: Ensure one blank line before and after headings and code blocks.
Workflow
1. Inspect the file
Read the markdown file to understand its current state.
2. Run the formatter script
Execute scripts/format_md.py with the target path. Check the diff output.
3. Verify formatting
Read the formatted file to confirm changes are correct and no content was accidentally altered.
4. Iterate if needed
For complex documents, manually review or adjust formatting the script doesn't cover.
References
See references/heading-syntax.md for markdown heading specification details.
