[GH-ISSUE #216] Trailing whitespace that could produce a hard break but won't due to context should also be flagged by MD009 #2034

Closed
opened 2026-03-07 20:03:53 +03:00 by kerem · 4 comments
Owner

Originally created by @TheJaredWilcurt on GitHub (Aug 25, 2019).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/216

* Example
  * The next line has 2 spaces
  
  * The line above this should be flagged for trailing whitespace

There are two spaces on the 3rd line that should be flagged as trailing whitespace.
Here are the rules I'm using, in case I have something set wrong:

Here it is again, but with the spaces replaced by hearts to make it easier to see

*♥asdf
♥♥*♥zxcv
♥♥
♥♥*♥qwer
Originally created by @TheJaredWilcurt on GitHub (Aug 25, 2019). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/216 ```md * Example * The next line has 2 spaces * The line above this should be flagged for trailing whitespace ``` There are two spaces on the 3rd line that should be flagged as trailing whitespace. Here are the rules I'm using, in case I have something set wrong: * https://github.com/TheJaredWilcurt/tjw-markdownlint-rules/blob/master/tjwmarkdownlint.yml Here it is again, but with the spaces replaced by hearts to make it easier to see ```md *♥asdf ♥♥*♥zxcv ♥♥ ♥♥*♥qwer ```
kerem 2026-03-07 20:03:53 +03:00
Author
Owner

@DavidAnson commented on GitHub (Aug 25, 2019):

Exactly 2 trailing spaces has a special meaning in Markdown. If you change your example to just one space or three+, MD009 will fire as expected. You can use the br_spaces perimeter to report issues for two spaces as well. More detail is available in the documentation here: https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md009---trailing-spaces

<!-- gh-comment-id:524663882 --> @DavidAnson commented on GitHub (Aug 25, 2019): Exactly 2 trailing spaces has a special meaning in Markdown. If you change your example to just one space or three+, MD009 will fire as expected. You can use the `br_spaces` perimeter to report issues for two spaces as well. More detail is available in the documentation here: https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md009---trailing-spaces
Author
Owner

@TheJaredWilcurt commented on GitHub (Aug 26, 2019):

I understand the 2 spaces being a <br>, but that should only be at the end of a line with content.

In this context, it is obvious that it is an indentation placed by the editor and would not be interpreted to produce a <br>. It is continuing the indentation of the previous line.

* Example
  * two space indent
    * four spaces
    
    * The above line also has 4 spaces

When it's an empty line, with nothing but spaces, in the middle of a list, it should let you auto-flag that.

<!-- gh-comment-id:524897772 --> @TheJaredWilcurt commented on GitHub (Aug 26, 2019): I understand the 2 spaces being a `<br>`, but that should only be at the end of a line with content. In this context, it is obvious that it is an indentation placed by the editor and would not be interpreted to produce a `<br>`. It is continuing the indentation of the previous line. ```md * Example * two space indent * four spaces * The above line also has 4 spaces ``` When it's an empty line, with nothing but spaces, in the middle of a list, it should let you auto-flag that.
Author
Owner

@DavidAnson commented on GitHub (Aug 26, 2019):

Using the br_spaces parameter I reference above should report for your original example.

MD009 could also be enhanced to understand scenarios where trailing spaces do not insert a hard break and report on that in the default configuration. Is that what you are looking for?

Context: https://spec.commonmark.org/0.29/#hard-line-breaks

<!-- gh-comment-id:524923697 --> @DavidAnson commented on GitHub (Aug 26, 2019): Using the `br_spaces` parameter I reference above should report for your original example. MD009 could also be enhanced to understand scenarios where trailing spaces do not insert a hard break and report on that in the default configuration. Is that what you are looking for? Context: https://spec.commonmark.org/0.29/#hard-line-breaks
Author
Owner

@TheJaredWilcurt commented on GitHub (Aug 27, 2019):

Yes, that is what I want. I'd like it to flag where trailing spaces are used but do not produce a <br>.

<!-- gh-comment-id:525434153 --> @TheJaredWilcurt commented on GitHub (Aug 27, 2019): Yes, that is what I want. I'd like it to flag where trailing spaces are used but do not produce a `<br>`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#2034
No description provided.