mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 09:16:02 +03:00
[GH-ISSUE #305] [MD012] Allow/enforce multiple blank lines before heading to add visual gaps #2109
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#2109
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 @wedi on GitHub (Jul 12, 2020).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/305
Hi,
it would be cool if there were a configuration option that allows (to enforce) more than one blank line before a heading.
Reasoning: If you rarely read the rendered version of a Markdown file but often look into the source, either to make modifications or to find some information in a cloned project, it would be of much help to have some visual gaps between sections. Just like the differently sized margins in a rendered document. Personally, I think this makes it much easier to find what you look for, especially in longer documents.
Overengineered version:
I looked into the
MD012function to do the allow part but I haven't found a way to determine if the current line contains a heading. I guess you need to checktoken.typeof the first token in the line but how do you get that token? Or would you need to extend the (a bit cryptic)getLineMetadatafunction along the lines ofinBreakandonFence?@younger-1 commented on GitHub (Jul 27, 2020):
With such rule, it will be very nice to read rendered MD files. 😄
@younger-1 commented on GitHub (Jul 28, 2020):
Surprise! 😺 There are other solution to get this down.
With Rule MD022, you can add random number of empty lines above or below headings.
In short, you can add this to your
setting.json:@younger-1 commented on GitHub (Jul 28, 2020):
By the way, I wonder if there is a way to precisely control the number of blank lines of different headings.
Like this: I want the <h1/h2/h3> headings with 6 blank lines before them and the <h4/h5/h6> headings with 3 blank lines before them.
So after rendering MD files, the 'Biger' headings can have more line before them. This can be helpful to look through the files
@DavidAnson commented on GitHub (Jul 28, 2020):
Yes, thanks @younger-1, what you show with https://github.com/DavidAnson/markdownlint/issues/305#issuecomment-664735479 is what @wedi was asking for. I will close this issue.
Your question at https://github.com/DavidAnson/markdownlint/issues/305#issuecomment-664739001 is not currently supported, but could be an enhancement.
@younger-1 commented on GitHub (Jul 28, 2020):
@DavidAnson Oh, yes! Thank you for your great work!
@wedi commented on GitHub (Jul 28, 2020):
Thanks for pointing this out, @younger-1! This reminds me that I already stumbled upon this issue quite some time ago and saw this myself back then. 🤗
But since I have already opened this ticket, I'd like to ask if it might be reasonable to merge MD012 and MD022 into one rule caring about blank lines everywhere. This would work around the limitation that you cannot have less blank lines allowed in MD012 as you set in MD022 (mentioned in https://github.com/DavidAnson/markdownlint/issues/143#issuecomment-478334254). This would also be the place to implement the suggestion above to have different spaces between different heading levels (https://github.com/DavidAnson/markdownlint/issues/305#issuecomment-664739001).
@waldyrious commented on GitHub (Aug 1, 2020):
I'm with @wedi here — requiring an increase of
MD012/no-multiple-blanks'smaximumto allow multiple lines above a heading also makes it impossible to require no multiple blank lines in other contexts, so IMO this issue should not be closed as the current workaround has drawbacks.A somewhat backward-compatible fix could be to simply make the values of
MD022/blanks-around-headersoverride MD012's, but I agree that a cleaner solution would be to have a single rule for blank lines.@DavidAnson commented on GitHub (Aug 1, 2020):
@waldyrious @wedi I understand what you are both saying. I intend to close this issue because it has been addressed. If you’d like to open a new issue for merging those two rules, I will leave that open and label it accordingly. Thank you!