[MD012] Allow/enforce multiple blank lines before heading to add visual gaps
See original GitHub issueHi,
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:
- Allow/enforce multiple blank lines only if the previous non blank line is not a heading.
- Allow/enforce different settings in different nesting levels.
I looked into the MD012
function 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 check token.type
of the first token in the line but how do you get that token? Or would you need to extend the (a bit cryptic) getLineMetadata
function along the lines of inBreak
and onFence
?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:8 (2 by maintainers)
Top GitHub Comments
@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!
I’m with @wedi here — requiring an increase of
MD012
/no-multiple-blanks
’smaximum
to 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-headers
override MD012’s, but I agree that a cleaner solution would be to have a single rule for blank lines.