[GH-ISSUE #1345] MD029/ol-prefix: an extra space is needed for code fences in lists with more than 10 elements #669

Closed
opened 2026-03-03 01:28:55 +03:00 by kerem · 4 comments
Owner

Originally created by @zachliu on GitHub (Sep 3, 2024).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1345

I created a list with more than 10 entries. All of them have a code block in it.

See example:

# Test

1. ...
2. ...
   1. three spaces here
   2. three spaces here
3. ...:

   ```bash
   three spaces here
   ```

4. ...:

   ```bash
   three spaces here
   ```

5. ...:

   ```bash
   three spaces here
   ```

6. ...:

   ```bash
   three spaces here
   ```

7. ...:

   ```bash
   three spaces here
   ```

8. ...:

   ```bash
   three spaces here
   ```

9. ...:

   ```bash
   three spaces here
   ```

10. ...:

    ```bash
    double tab (four spaces) here
    ```

11. ...:

    ```bash
    double tab (four spaces) here
    ```

12. ...:

    ```bash
    double tab (four spaces) here
    ```

I discovered that I had to use 4 spaces instead of 3 (mentioned in https://github.com/DavidAnson/markdownlint/issues/38 and https://github.com/DavidAnson/markdownlint/issues/125) for code fences if their index number is >= 10 otherwise I get MD029/ol-prefix Ordered list item prefix [Expected: 1; Actual: 11; Style: 1/2/3] on items 11, 12, ... etc (interestingly not on item 10).

Originally created by @zachliu on GitHub (Sep 3, 2024). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1345 I created a list with more than 10 entries. All of them have a code block in it. See example: ``````markdown # Test 1. ... 2. ... 1. three spaces here 2. three spaces here 3. ...: ```bash three spaces here ``` 4. ...: ```bash three spaces here ``` 5. ...: ```bash three spaces here ``` 6. ...: ```bash three spaces here ``` 7. ...: ```bash three spaces here ``` 8. ...: ```bash three spaces here ``` 9. ...: ```bash three spaces here ``` 10. ...: ```bash double tab (four spaces) here ``` 11. ...: ```bash double tab (four spaces) here ``` 12. ...: ```bash double tab (four spaces) here ``` `````` I discovered that I had to use `4` spaces instead of `3` (mentioned in https://github.com/DavidAnson/markdownlint/issues/38 and https://github.com/DavidAnson/markdownlint/issues/125) for code fences if their index number is >= 10 otherwise I get `MD029/ol-prefix Ordered list item prefix [Expected: 1; Actual: 11; Style: 1/2/3]` on items 11, 12, ... etc (interestingly not on item 10).
kerem 2026-03-03 01:28:55 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Sep 3, 2024):

Your example above produces no warnings from markdownlint as-is. The code fences in list items 10 and above need four spaces of indent because that's what corresponds to the first character after the previous list item marker. Specifically, "9. " is only three characters whereas "10. " is four, and thus the change. Per the CommonMark specification, using fewer spaces than required to nest the code fence within a list item causes the next list item marker to begin a new list. For example, insufficiently indenting the list in item 10 causes a warning for item 11 because it creates a new list that doesn't start with 1. So far as I can tell, everything here is correct and operating as intended.

<!-- gh-comment-id:2327560053 --> @DavidAnson commented on GitHub (Sep 3, 2024): Your example above produces no warnings from markdownlint as-is. The code fences in list items 10 and above need four spaces of indent because that's what corresponds to the first character after the previous list item marker. Specifically, "9. " is only three characters whereas "10. " is four, and thus the change. Per the CommonMark specification, using fewer spaces than required to nest the code fence within a list item causes the next list item marker to begin a new list. For example, insufficiently indenting the list in item 10 causes a warning for item 11 because it creates a new list that doesn't start with 1. So far as I can tell, everything here is correct and operating as intended.
Author
Owner

@zachliu commented on GitHub (Sep 3, 2024):

sorry for the confusion. the example was provided so that it produced no warnings

2024-09-03_19-44

had i not used 4 spaces for 10, 11, and 12, i would get the warnings

<!-- gh-comment-id:2327638531 --> @zachliu commented on GitHub (Sep 3, 2024): sorry for the confusion. the example was provided so that it produced no warnings ![2024-09-03_19-44](https://github.com/user-attachments/assets/044c6007-8ab2-4f69-87aa-1139ac6d77de) had i not used 4 spaces for 10, 11, and 12, i would get the warnings
Author
Owner

@zachliu commented on GitHub (Sep 3, 2024):

The code fences in list items 10 and above need four spaces of indent because that's what corresponds to the first character after the previous list item marker. Specifically, "9. " is only three characters whereas "10. " is four, and thus the change.

i see the point 👍
the number of spaces needs is the same as the indexes themselves: 9. needs three, 10. needs four, 100. needs five

<!-- gh-comment-id:2327640520 --> @zachliu commented on GitHub (Sep 3, 2024): > The code fences in list items 10 and above need four spaces of indent because that's what corresponds to the first character after the previous list item marker. Specifically, "9. " is only three characters whereas "10. " is four, and thus the change. i see the point :+1: the number of spaces needs is the same as the indexes themselves: `9. ` needs three, `10. ` needs four, `100. ` needs five
Author
Owner

@DavidAnson commented on GitHub (Sep 4, 2024):

Right, without at least that many spaces, the code fence is not part of the list item as can be seen in this example where the middle fence has 3 instead of 4 spaces of indent: https://dlaa.me/markdownlint/#%25m%23%20Test%0A%0A9.%20...%3A%0A%0A%20%20%20%60%60%60bash%0A%20%20%20three%0A%20%20%20%60%60%60%0A%0A10.%20...%3A%0A%0A%20%20%20%60%60%60bash%0A%20%20%20three%0A%20%20%20%60%60%60%0A%0A11.%20...%3A%0A%0A%20%20%20%20%60%60%60bash%0A%20%20%20%20four%0A%20%20%20%20%60%60%60%0A

<!-- gh-comment-id:2327662231 --> @DavidAnson commented on GitHub (Sep 4, 2024): Right, without at least that many spaces, the code fence is not part of the list item as can be seen in this example where the middle fence has 3 instead of 4 spaces of indent: https://dlaa.me/markdownlint/#%25m%23%20Test%0A%0A9.%20...%3A%0A%0A%20%20%20%60%60%60bash%0A%20%20%20three%0A%20%20%20%60%60%60%0A%0A10.%20...%3A%0A%0A%20%20%20%60%60%60bash%0A%20%20%20three%0A%20%20%20%60%60%60%0A%0A11.%20...%3A%0A%0A%20%20%20%20%60%60%60bash%0A%20%20%20%20four%0A%20%20%20%20%60%60%60%0A
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#669
No description provided.