MD064 - No Multiple Consecutive Spaces¶
Aliases: no-multiple-consecutive-spaces
Rule Details¶
This rule is triggered when multiple consecutive spaces (2 or more) are found in markdown content. Multiple spaces between words serve no purpose in markdown and typically indicate formatting issues or copy-paste artifacts.
Rationale¶
Multiple consecutive spaces in markdown:
- Render as single space: Most markdown renderers collapse multiple spaces into a single space, so extra spaces have no visual effect
- Indicate potential issues: Often result from copy-paste errors or accidental keystrokes
- Reduce readability: Make the source markdown harder to read
Examples¶
Incorrect¶
Correct¶
Exceptions¶
This rule does NOT flag spaces in the following contexts:
1. Inline Code Spans¶
Spaces inside inline code are intentional and preserved:
2. Fenced/Indented Code Blocks¶
Code block content is not processed:
3. Leading Indentation¶
Leading whitespace for structure is preserved:
4. Trailing Spaces¶
All trailing spaces are handled by MD009 and are not flagged by this rule:
Use MD009 to control trailing space behavior.
5. Front Matter¶
YAML/TOML/JSON front matter is not processed:
6. HTML Comments¶
Content inside HTML comments is not processed:
7. HTML Blocks¶
Content inside HTML block elements is not processed.
8. Table Rows¶
Table rows with alignment padding are not flagged:
GFM-style tables without leading/trailing pipes are also skipped:
The spaces used for visual alignment in tables are intentional.
9. List Marker Spacing¶
Spaces after list markers are handled by MD030, not MD064:
10. Blockquote Marker Spacing¶
Spaces after blockquote markers are handled by MD027:
11. Reference Link Definitions¶
Spaces after the colon in reference link definitions:
12. Footnote Markers¶
Spaces after footnote markers:
13. Definition List Markers¶
Spaces after definition list markers (PHP Markdown Extra / Pandoc):
14. Task List Checkboxes¶
Spaces after task list checkboxes:
Fix¶
The automatic fix collapses multiple consecutive spaces to a single space.
Before:
After:
When allow-sentence-double-space is enabled, the fix preserves exactly 2
spaces after sentence boundaries while collapsing other multiple spaces to 1.
Configuration¶
| Option | Type | Default | Description |
|---|---|---|---|
allow-sentence-double-space |
boolean | false | Allow exactly 2 spaces after sentence-ending punctuation |
allow-sentence-double-space¶
The allow-sentence-double-space option enables the traditional typographical
convention of using two spaces after sentence-ending punctuation (., !, ?)
while still flagging multiple spaces elsewhere:
With this configuration:
End of sentence. Start of next sentence. <- OK (2 spaces after period)
Multiple spaces in middle of sentence. <- Flagged (not after sentence)
What a question! Here's the answer. <- OK (2 spaces after !)
Really? Yes, really. <- OK (2 spaces after ?)
Recognized Sentence Boundaries¶
The rule recognizes sentences ending with:
- Period (.) followed by spaces (not part of ellipsis or abbreviation)
- Exclamation mark (!)
- Question mark (?)
Closing punctuation after the sentence-ending punctuation is handled correctly:
"End quote." Next sentence. <- OK (period inside quotes)
She said "Hello!" He replied. <- OK (! inside quotes)
(See appendix.) More content. <- OK (period inside parens)
The book [2024]. Next reference. <- OK (period inside brackets)
Ellipsis Handling¶
Ellipsis (...) is treated as a sentence boundary, allowing double space after:
Disabling the Rule¶
To disable this rule entirely:
Related Rules¶
- MD009 - Trailing spaces (handles trailing whitespace)
- MD010 - Hard tabs (handles tab characters)
- MD012 - Multiple consecutive blank lines
- MD027 - Multiple spaces after blockquote symbol
- MD030 - Spaces after list markers
Version¶
Added in rumdl v0.0.196.