[GH-ISSUE #968] MD048: Make it automatically fixable #575

Open
opened 2026-03-03 01:28:08 +03:00 by kerem · 3 comments
Owner

Originally created by @skwde on GitHub (Sep 13, 2023).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/968

The description of rules at https://github.com/DavidAnson/vscode-markdownlint#rules is followed by the list of fixable rules.

MD048 seems fairly easy to fix (I also haven't found info on why it is not fixable).

So can it be done or is there a good reason why it is not?

Originally created by @skwde on GitHub (Sep 13, 2023). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/968 The description of rules at <https://github.com/DavidAnson/vscode-markdownlint#rules> is followed by the list of fixable rules. MD048 seems fairly easy to fix (I also haven't found info on why it is not fixable). So can it be done or is there a good reason why it is not?
Author
Owner

@DavidAnson commented on GitHub (Sep 13, 2023):

This looks like an oversight. I'll implement this soon.

<!-- gh-comment-id:1717953893 --> @DavidAnson commented on GitHub (Sep 13, 2023): This looks like an oversight. I'll implement this soon.
Author
Owner

@DavidAnson commented on GitHub (Sep 16, 2023):

This isn't implemented because it requires a single fix that touches both the open and close of the fence (different lines) and that is not easily possible today. It will be possible someday and this behavior should be straightforward to implement then.

<!-- gh-comment-id:1722118864 --> @DavidAnson commented on GitHub (Sep 16, 2023): This isn't implemented because it requires a single fix that touches both the open and close of the fence (different lines) and that is not easily possible today. It will be possible someday and this behavior should be straightforward to implement then.
Author
Owner

@wisnij commented on GitHub (Feb 21, 2026):

I was taking a stab at this one recently and only belatedly found this issue. The roadblock I ran into is that this rule has an interaction with MD031/blanks-around-fences – if both rules are enabled and the opening fence is not preceded by a blank line, they both need to emit a fix at the same location, but only one of them can actually be applied (if I understand the logic in applyFixes properly, anyway).

It looks like the options here are:

  1. Make it possible to apply more than one fix at the same location
  2. Allow one rule to detect whether another is enabled, to modify its own behavior accordingly
  3. Just leave this one unfixable

Option 1 would obviously be ideal, but it might not be possible in the general case if there are genuine conflicts. As for option 2, I certainly understand the desire to keep rules independent, but FWIW I would submit that these two rules are already coupled due to triggering on the same lines. Introducing a direct reference between them would not be adding new coupling but converting the existing implicit coupling into an explicit one, which seems less bad, at least.

Here's as far as I've gotten so far, in the hope that it helps:

https://github.com/DavidAnson/markdownlint/compare/main...wisnij:markdownlint:wisnij/20260220-fix-md048

<!-- gh-comment-id:3938328670 --> @wisnij commented on GitHub (Feb 21, 2026): I was taking a stab at this one recently and only belatedly found this issue. The roadblock I ran into is that this rule has an interaction with `MD031/blanks-around-fences` – if both rules are enabled and the opening fence is not preceded by a blank line, they both need to emit a fix at the same location, but only one of them can actually be applied (if I understand the logic in `applyFixes` properly, anyway). It looks like the options here are: 1. Make it possible to apply more than one fix at the same location 2. Allow one rule to detect whether another is enabled, to modify its own behavior accordingly 3. Just leave this one unfixable Option 1 would obviously be ideal, but it might not be possible in the general case if there are genuine conflicts. As for option 2, I certainly understand the desire to keep rules independent, but FWIW I would submit that these two rules are _already_ coupled due to triggering on the same lines. Introducing a direct reference between them would not be adding new coupling but converting the existing implicit coupling into an explicit one, which seems less bad, at least. Here's as far as I've gotten so far, in the hope that it helps: https://github.com/DavidAnson/markdownlint/compare/main...wisnij:markdownlint:wisnij/20260220-fix-md048
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#575
No description provided.