question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[MD012] Allow/enforce multiple blank lines before heading to add visual gaps

See original GitHub issue

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:

  • 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
DavidAnsoncommented, 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!

0reactions
waldyriouscommented, Aug 1, 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.

I’m with @wedi here — requiring an increase of MD012/no-multiple-blanks’s maximum 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create two blank lines in Markdown - Stack Overflow
The non-breaking space ASCII character   (followed by a blank line) would give a blank line. Repeating this pair would do the job....
Read more >
Table of content extra blank line added between heading 2 ...
Right-click on it and on the context menu that pops up, select paragraph. Image; Is there space before or space after formatting? Set...
Read more >
Style Guide - Pylearner
Note: this rule will fire if either side of the header contains multiple spaces. MD022 - Headers should be surrounded by blank lines....
Read more >
Using Standard Text Formatting For Headings - WCAG WG
The programmatic identification of the Heading is the two blank lines ... user would decipher headings by visually identifying the space before it...
Read more >
This video explains how to get rid of blank lines in Microsoft ...
This is a Microsoft Word tutorial covering, how to get rid of blank lines, heading styles, line spaces and default paragraph settings.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found