markdownlint icon indicating copy to clipboard operation
markdownlint copied to clipboard

Ordered lists should be allowed variable number of spaces after prefixes

Open gspencergoog opened this issue 4 months ago • 5 comments

When an ordered list is formatted as so:

1.  one
2.  two
3.  three
4.  four
5.  five
6.  six
7.  seven
8.  eight
9.  nine
10. ten
11. eleven

Where there are two spaces after items 1-9, and only one after 10 and 11, Markdownlint will mark the lines with items 1-9 with the error:

MD030/list-marker-space: Spaces after list markers [Expected: 1; Actual: 2]markdownlintMD030`

This indentation scheme is common, since it aligns the start of the item text in lists with more than nine items. A generalized lint might allow as many spaces as there are digits in the number of max items minus the number of digits in the current item, plus the value of ol_multi.

I think a new style option for MD030 might be in order to allow this, or at least a way to specify a range for allowed number of spaces for ordered lists.

gspencergoog avatar Sep 02 '25 22:09 gspencergoog

I think I prefer the “leading spaces” style shown here which is already supported: https://github.com/DavidAnson/markdownlint/blob/main/test/list-item-prefix-alignment.md

DavidAnson avatar Sep 03 '25 00:09 DavidAnson

I think I prefer the “leading spaces” style shown here which is already supported: main/test/list-item-prefix-alignment.md

TBH, so do I, but LLMs (at least Gemini) seem to prefer this output format, and I have to turn off MD030 entirely if I don't want to constantly be fixing them or seeing warnings, and that means I sometimes miss other violations of this lint.

For me, having an auto-fix for MD030 that would fix the number of spaces would be almost as good: I already apply auto-fixes routinely, and the main one that I have to fix manually is this one.

gspencergoog avatar Sep 03 '25 01:09 gspencergoog

@gspencergoog, you can prompt gemini to produce the output using leading spaces.

Some writers using the extended markdown (MDX) in combination with this linter, type a list manually. Unlike the regular .md format, new numbers aren’t generated for each new lines.

network-charles avatar Oct 01 '25 07:10 network-charles

you can prompt gemini to produce the output using leading spaces.

I have tried this (even before I filed this issue), and it says it will, and then ignores the instructions. I think it is embedded in the training data too strongly.

gspencergoog avatar Oct 01 '25 15:10 gspencergoog

I guess so. ChatGPT works.

https://chatgpt.com/s/t_68dd70acebc4819197e1122423012d1d

I don't think this enhancement is scalable. Like I previously mentioned, it’ll affect the extended markdown users.

network-charles avatar Oct 01 '25 18:10 network-charles