mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 01:05:55 +03:00
[GH-ISSUE #990] MD012: Allow it (no-multiple-blanks) to work with MD022 (blanks-around-headings) #2429
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#2429
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 @waldyrious on GitHub (Sep 27, 2023).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/990
This was previously proposed in the context of #305, but was beyond the scope of that issue. A new issue was recommended at the time, but I never got around to create one. Until now, that is 😄
The problem: currently setting MD022/blanks-around-headings to any value other than the default (1) can conflict with MD012/no-multiple-blanks, whose default value is 1.
In #305 the proposed workaround was to increase MD012/no-multiple-blanks's maximum to the number of lines specified for a heading; however, that makes it impossible to prevent the occurrence of multiple blank lines in other contexts.
One possible solution would be to have the values of MD022 override MD012's (similar to how in CSS more specific selectors override more generic ones); but perhaps that CSS analogy already hints at what would IMHO be a cleaner solution: since multiple blank lines around headings are a special case of multiple blanks, it seems reasonable to add parameters to MD012 to allow specifying custom values in that specific context. Something like this, for example:
For prior art about rules that support parameters to apply differently in different contexts, see:
code_blocks,headingsandtablesparameters;ol_multi,ol_single,ul_multiandul_singleparametersallowed_elementsparameterI don't think we need additional parameters for other elements, but I'll mention the possibility nevertheless in case it may be considered a more consistent approach overall: this proposal of extending MD012 could subsume not just MD022, but also MD028/no-blanks-blockquote, MD031/blanks-around-fences, and MD032/blanks-around-lists.
/cc @wedi
@DavidAnson commented on GitHub (Sep 28, 2023):
Thinking about this very briefly, I feel like this rule should peek at any customizations applied to other built-in rules and respect them. (Although right now it does not have access to that information.) Merging some of the rules you list together does not feel right because they express different intents.
@waldyrious commented on GitHub (Sep 28, 2023):
Sure — if you feel that approach makes sense, fine by me. I was under the impression that the rules were meant to be more or less independent, though, and would work consistently given the same configuration. Is there any instance of a rule's behavior being dependent on other rules' configurations?
@DavidAnson commented on GitHub (Sep 28, 2023):
Rules are meant to be independent, and what I propose here would obviously not coordinate with any custom rules. There is no precedent for this, but it's the option I dislike least so far. :)