[GH-ISSUE #546] MD022: Split into two separate configurations to allow enforcing only one of lines_above/lines_below #446

Closed
opened 2026-03-03 01:26:59 +03:00 by kerem · 2 comments
Owner

Originally created by @MicahZoltu on GitHub (Aug 2, 2022).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/546

https://github.com/DavidAnson/markdownlint/blob/main/README.md#md022---headings-should-be-surrounded-by-blank-lines

Unless I'm missing something, it doesn't appear I can configure markdownlint to enforce lines_above while not enforcing lines_below. IIUC, I can only either turn the whole rule off, or configure linting on both. I would like to enforce lines_above but not enforce lines_below.

Originally created by @MicahZoltu on GitHub (Aug 2, 2022). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/546 https://github.com/DavidAnson/markdownlint/blob/main/README.md#md022---headings-should-be-surrounded-by-blank-lines Unless I'm missing something, it doesn't appear I can configure markdownlint to enforce `lines_above` while not enforcing `lines_below`. IIUC, I can only either turn the whole rule off, or configure linting on both. I would like to enforce `lines_above` but *not* enforce `lines_below`.
kerem 2026-03-03 01:26:59 +03:00
Author
Owner

@DavidAnson commented on GitHub (Aug 2, 2022):

Can you explain more, please? It sounds like you want to ensure there is exactly one line above the heading, but do not care if there are 0, 1, 10, etc. lines below it and if that amount varies within the same file? Why?

<!-- gh-comment-id:1202922223 --> @DavidAnson commented on GitHub (Aug 2, 2022): Can you explain more, please? It sounds like you want to ensure there is exactly one line above the heading, but do not care if there are 0, 1, 10, etc. lines below it and if that amount varies within the same file? Why?
Author
Owner

@MicahZoltu commented on GitHub (Aug 2, 2022):

This is correct. There are 3 reasons one may want to do this:

  1. If you are only linting for compatibility, then lines_above is necessary for maximum rendering engine compatibility while lines_below is not.
  2. In some contexts, having 0 lines below makes sense, such as when you have a fairly concise document with a single paragraph per heading. In other contexts, having 1 line below makes sense, such as when the content within each section is multiple paragraphs.
  3. Within a given document, it may make sense to have top level headings (# and ##) with lines below while deeply nested headings it may make sense to have 0 lines below.
<!-- gh-comment-id:1202975517 --> @MicahZoltu commented on GitHub (Aug 2, 2022): This is correct. There are 3 reasons one may want to do this: 1. If you are only linting for compatibility, then `lines_above` is necessary for maximum rendering engine compatibility while `lines_below` is not. 2. In some contexts, having 0 lines below makes sense, such as when you have a fairly concise document with a single paragraph per heading. In other contexts, having 1 line below makes sense, such as when the content within each section is multiple paragraphs. 3. Within a given document, it may make sense to have top level headings (# and ##) with lines below while deeply nested headings it may make sense to have 0 lines below.
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#446
No description provided.