Markdown Formatter
Formats and cleans up Markdown files following consistent style rules.
Features
- •Fix heading hierarchy (no skipped levels)
- •Normalize list markers (consistent
-or*) - •Add or update table of contents
- •Fix trailing whitespace
- •Ensure files end with newline
- •Format tables with aligned columns
Usage
When the user asks to format a Markdown file:
- •Read the target file
- •Apply formatting rules
- •Write the formatted content back
- •Report what changed
Formatting Rules
Headings:
- •Ensure a single H1 at the top
- •No skipped heading levels (H1 → H3 without H2)
- •Add blank line before and after headings
Lists:
- •Use
-for unordered lists - •Use
1.for ordered lists (auto-number) - •Indent nested lists with 2 spaces
Code blocks:
- •Ensure language identifier on fenced blocks
- •Use triple backticks (not tildes)
Tables:
- •Align columns with padding
- •Ensure header separator row exists
Example
Input:
markdown
# Title ### Skipped heading * Mixed - list - markers
Output:
markdown
# Title ## Skipped heading - Mixed - list - markers
Notes
- •Always create a backup before modifying files
- •Report the number of changes made
- •Respect
.editorconfigif present in the project