mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 17:26:22 +03:00
[GH-ISSUE #1899] MD012 shall make it possible, that files end with a blank line as recommended #2620
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#2620
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jamilraichouni on GitHub (Dec 20, 2025).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1899
Hi!
I use
markdownlint v0.47.0.It is recommended and very common that files end with a blank line:
The rule
MD012/no-multiple-blanksdoes not allow that. I do not want to disable the rule for the whole of my Markdown files. The rule makes sense everywhere except for the end of the file.Example:
results in
I think that this needs a fix.
Many thanks,
Jamil
@DavidAnson commented on GitHub (Dec 20, 2025):
After un-escaping "\n", your document produces no violations.
https://dlaa.me/markdownlint/#%25m%23%20My%20title%0A%0AThis%20is%20my%20doc.%0A
My guess is that the "echo" command you are using adds its own trailing newline character which causes there to be two at the end of the input.
@jamilraichouni commented on GitHub (Dec 20, 2025):
Well, I used the
echocommand just here to make it an easy to reproduce example.Any file in
vimI edit has that issue when I want to let it end with a blank line:Try this with a test file, please.
@DavidAnson commented on GitHub (Dec 20, 2025):
Your original example uses
echowhich is documented to add a newline at the end of its output. Therefore, your example has multiple newlines and the output you show frommarkdownlintis correct. We can fix your sample to omit the newline fromecho(by adding-n) and confirm that no violations are reported for a file with a single trailing newline:You asked to see a test file and we can do that, too, by creating your test file and then verifying its contents visually and at the byte level:
Linting this file directly or as piped input produces no violations as expected:
I don't know how you have
vimconfigured, but any issues there are outside the scope of this project.@jamilraichouni commented on GitHub (Dec 20, 2025):
Thanks, you're right.