[GH-ISSUE #125] "MD029 - Ordered list item prefix" when list includes code blocks in fences #1953

Closed
opened 2026-03-07 20:03:05 +03:00 by kerem · 6 comments
Owner

Originally created by @jpluimers on GitHub (Jun 6, 2018).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/125

The below code throws https://github.com/DavidAnson/markdownlint/blob/v0.10.0/doc/Rules.md#md029 on the last line.

## Test

1. Run this script:

  ``` batch
  cls
  ```

2. Start Task Manager

Markdown rendering works fine though, as the second item is indeed numbered "2":

Test

  1. Run this script:
cls
  1. Start Task Manager
Originally created by @jpluimers on GitHub (Jun 6, 2018). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/125 The below code throws https://github.com/DavidAnson/markdownlint/blob/v0.10.0/doc/Rules.md#md029 on the last line. ## Test 1. Run this script: ``` batch cls ``` 2. Start Task Manager Markdown rendering works fine though, as the second item is indeed numbered "2": ## Test 1. Run this script: ``` batch cls ``` 2. Start Task Manager
kerem 2026-03-07 20:03:05 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Jun 6, 2018):

Your idea to test for same/new list was good, but thwarted by the fact some parsers allow list number continuation. :)

The following tweak to your example demonstrates that your scenario is actually two lists, not one, so the reported violation is correct:

## Test

1. Run this script:

  ``` batch
  cls
  ```

1. Start Task Manager
1. Fin

The fix is to indent the code fence 3 spaces to line up with the start of first column of the list item above which tells the parser it is part of the item (not a separate block):

## Test

1. Run this script:

   ``` batch
   cls
   ```

1. Start Task Manager
1. Fin
<!-- gh-comment-id:395127149 --> @DavidAnson commented on GitHub (Jun 6, 2018): Your idea to test for same/new list was good, but thwarted by the fact some parsers allow list number continuation. :) The following tweak to your example demonstrates that your scenario is actually two lists, not one, so the reported violation is correct: ```` ## Test 1. Run this script: ``` batch cls ``` 1. Start Task Manager 1. Fin ```` The fix is to indent the code fence 3 spaces to line up with the start of first column of the list item above which tells the parser it is part of the item (not a separate block): ```` ## Test 1. Run this script: ``` batch cls ``` 1. Start Task Manager 1. Fin ````
Author
Owner

@DavidAnson commented on GitHub (Jun 6, 2018):

Here’s a link to the updated sample in the markdown-it parser: sample

<!-- gh-comment-id:395128848 --> @DavidAnson commented on GitHub (Jun 6, 2018): Here’s a link to the updated sample in the `markdown-it` parser: [sample](https://markdown-it.github.io/#md3=%7B%22source%22%3A%22%23%23%20Test%5Cn%5Cn1.%20Run%20this%20script%3A%5Cn%5Cn%20%20%60%60%60%20batch%5Cn%20%20cls%5Cn%20%20%60%60%60%5Cn%5Cn1.%20Start%20Task%20Manager%5Cn1.%20Fin%22%2C%22defaults%22%3A%7B%22html%22%3Afalse%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22html%22%7D%7D)
Author
Owner

@jpluimers commented on GitHub (Jun 6, 2018):

Thanks for teaching me this. I never noticed that markdown can start lists at non-1.

<!-- gh-comment-id:395162806 --> @jpluimers commented on GitHub (Jun 6, 2018): Thanks for teaching me this. I never noticed that markdown can start lists at non-1.
Author
Owner

@ChristianStadelmann commented on GitHub (Jan 19, 2021):

@DavidAnson wrote:

The fix is to indent the code fence 3 spaces to line up with the start of first column of the list item above which tells the parser it is part of the item (not a separate block):

## Test

1. Run this script:

   ``` batch
   cls
  1. Start Task Manager
  2. Fin

Actually, this gives you the MD046 warning. Is this by intention? Is something wrong with this example?

<!-- gh-comment-id:762923253 --> @ChristianStadelmann commented on GitHub (Jan 19, 2021): @DavidAnson wrote: > The fix is to indent the code fence 3 spaces to line up with the start of first column of the list item above which tells the parser it is part of the item (not a separate block): > > ``` > ## Test > > 1. Run this script: > > ``` batch > cls > ``` > > 1. Start Task Manager > 1. Fin > ``` Actually, this gives you the MD046 warning. Is this by intention? Is something wrong with this example?
Author
Owner

@DavidAnson commented on GitHub (Jan 19, 2021):

@ChristianStadelmann That example does not produce MD046: https://dlaa.me/markdownlint/#%25m%23%20Test%0A%0A1.%20Run%20this%20script%3A%0A%0A%20%20%20%60%60%60%20batch%0A%20%20%20cls%0A%20%20%20%60%60%60%0A%0A1.%20Start%20Task%20Manager%0A1.%20Fin%0A

You might be seeing it in your document if you are using the default "consistent" style and have an indented code block earlier in the document - that indented code and the example's fenced code would not be consistent.

<!-- gh-comment-id:762968861 --> @DavidAnson commented on GitHub (Jan 19, 2021): @ChristianStadelmann That example does not produce MD046: https://dlaa.me/markdownlint/#%25m%23%20Test%0A%0A1.%20Run%20this%20script%3A%0A%0A%20%20%20%60%60%60%20batch%0A%20%20%20cls%0A%20%20%20%60%60%60%0A%0A1.%20Start%20Task%20Manager%0A1.%20Fin%0A You might be seeing it in your document if you are using the default "consistent" style and have an indented code block earlier in the document - that indented code and the example's fenced code would not be consistent.
Author
Owner

@ChristianStadelmann commented on GitHub (Jan 20, 2021):

Ok, thanks for explaining!

<!-- gh-comment-id:763510149 --> @ChristianStadelmann commented on GitHub (Jan 20, 2021): Ok, thanks for explaining!
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#1953
No description provided.