MD039 - Remove extra spaces in links¶
Aliases: no-space-in-links
What this rule does¶
Removes unnecessary spaces inside square brackets for link text and image descriptions.
Why this matters¶
- Clean appearance: Extra spaces make links look unprofessional
- Consistent formatting: All links should follow the same pattern
- Better readability: Clear link boundaries improve document flow
- Prevents broken links: Some parsers may not handle extra spaces correctly
Examples¶
✅ Correct¶
Link text directly touches the brackets:
[Visit our website](https://example.com)

[Reference link][docs]
Check the [API documentation](https://api.example.com) for details.
❌ Incorrect¶
Extra spaces inside square brackets:
[ Visit our website](https://example.com)
[Visit our website ](https://example.com)
[ Visit our website ](https://example.com)

🔧 Fixed¶
Spaces removed from inside brackets:
[Visit our website](https://example.com)
[Visit our website](https://example.com)
[Visit our website](https://example.com)

Configuration¶
This rule has no configuration options.
Automatic fixes¶
This rule will:
- Remove spaces after opening brackets
[ - Remove spaces before closing brackets
] - Work on both regular links and image alt text
- Handle reference-style links
- Preserve spaces within the link text itself
Learn more¶
Related rules¶
- MD034 - No bare URLs - Ensure URLs are properly formatted as links
- MD042 - No empty links - Ensure links have descriptive text
- MD051 - Link fragments should be valid - Check internal link targets