mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 01:05:55 +03:00
[GH-ISSUE #1902] MD055 add fixes #772
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#772
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 @non-zero-sum on GitHub (Dec 28, 2025).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1902
Current state as at v0.40.0:
MD055provides detection, but no fixes.Proposal: Add the following behaviour
expectedLeadingPipe && !actualLeadingPipe: insert|ahead of leading token in first cell of row!expectedLeadingPipe && actualLeadingPipe: remove|and any leading whitespace from first cell of rowexpectedTrailingPipe && !actualTrailingPipe: insert|after trailing token in last cell of row!expectedTrailingPipe && actualTrailingPipe: remove|and any trailing whitespace from last cell of rowNote: this would not guarantee passing
MD060(table-column-style), which would need a seperate fix.@non-zero-sum commented on GitHub (Dec 28, 2025):
As per comments in the PR regarding MD060 compatibility:
My initial thoughts on this are:
Option 0: do nothing
Leave the rule as-is without a fix
Option 1: Add/remove pipes (and whitespace) naively (as per PR)
Apply initial suggested logic.
Pros:
Cons:
MD060error whenaligned(oraligned_delimiter)tightorcompactconfiguration forMD060would depend on leading spaces already in the cell contenttightorcompactconfiguration forMD060would depend on trailing spaces in the cell content (andMD009)MD060errors withaligned(oraligned_delimiter) especially if fixing multiple rows of different content lengthMD060error ifalignedoraligned_delimiterNeutral:
MD060compactandtightImplication: the user (or an fix for
MD060) would need to take care of the alignmentOption 2: add an explicit parameter
Add parameters to the rule (e.g.
fix_style, with values matchingMD060'sstyleparameter) to allow the user to set the behaviour.Pros:
MD060if the user chose that behaviourCons:
anyoraligned_delimiterwould require more significant refactoring asMD055is not currently "table aware" as it acts on rows independently (except for first header row when usingconsistent)MD055andMD060requiring the settings to be kept in syncOption 3: apply spacing "consistently" with first table header
Apply the same approach to spaces as is currently done with
consistent(default) configuration for pipe presence/absence.Pros:
compactandtightconfiguration ofMD060Cons:
aligned(oraligned_delimiter) configuration ofMD060(as option 1)anyconfiguration ofMD060Implication: the user (or an fix for
MD060) would need to take care of the alignment for unsupported scenariosOption 4: apply spacing based on detection for each table
Use space around non-leading/trailing pipes to infer
MD060preference.Pros:
Cons:
MD060fixMD060Implication: the user (or an fix for
MD060) would need to take care of the alignment for unsupported scenariosOption 5: explicit coupling with
MD060(included for completeness)Pass the configuration for
MD060intoMD055Pros: as option 2
Cons:
@DavidAnson commented on GitHub (Dec 29, 2025):
This is incredibly thorough, thank you! Without having thought much about this myself yet, aspects of each of 2/3/4/5 concern me. Of those, 3/4 seem the most attractive at the moment (for 4, a bit of refactoring would allow sharing the common code). But I worry about what happens to someone who applies both rules to a new table - I want to avoid a situation where they recommend conflicting and/or infinite looping "fixes".
That said, there are two parts to option 1 and they can be done separately. Specifically, although ADDING pipes is potentially ambiguous, REMOVING them seems deterministic. When removing a leading or trailing pipe, that pipe and all whitespace "inside" the cell can be removed - for every table style. You point out this may cause an error by breaking column alignment which is valid. But for a scenario where a table starts consistent, I'd expect all rows to be adjusted similarly such that overall alignment does not change. This may need some experimentation to confirm.
So this may be a starting point. It's not mandatory that fixable rules fix ALL scenarios - it could be that this rule only fixes removal scenarios if that's all we feel confident about.
@non-zero-sum commented on GitHub (Jan 6, 2026):
To avoid clashes I would suggest:
this would mean at worst
MD055 -> MD060MD060 -> MD055@non-zero-sum commented on GitHub (Jan 6, 2026):
The only scenario I can think of where this wouldn't be the case is MD060
alignedwith non left-aligned cells.