[GH-ISSUE #200] Disable MD031 (space around code blocks) for lists? #2021

Closed
opened 2026-03-07 20:03:46 +03:00 by kerem · 2 comments
Owner

Originally created by @borekb on GitHub (Jun 16, 2019).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/200

The "MD031 – Fenced code blocks should be surrounded by blank lines" rule is invoked also for code blocks that are inside lists. (It was even reported as a bug when it wasn't: #189.) However, I'm not sure that it's desired because adding a blank line actually influences how the other <li> elements are treated (with a blank line, all of them are wrapped in an additional <p> tag).

Compare:

Example without a blank line

Source:

- List
- with
- code block:
    ```js
    console.log('hello world');
    ```

Output:

  • List
  • with
  • code block:
    console.log('hello world');
    

Example with a blank line

Source:

- List
- with
- code block:

    ```js
    console.log('hello world');
    ```

Output:

  • List

  • with

  • code block:

    console.log('hello world');
    

I'd appreciate if there was a way to disable MD031 for lists.

Originally created by @borekb on GitHub (Jun 16, 2019). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/200 The "MD031 – Fenced code blocks should be surrounded by blank lines" rule is invoked also for code blocks that are inside lists. (It was even reported as a bug when it wasn't: #189.) However, I'm not sure that it's desired because adding a blank line actually influences how the _other_ `<li>` elements are treated (with a blank line, _all_ of them are wrapped in an additional `<p>` tag). Compare: ## Example without a blank line **Source**: ```md - List - with - code block: ```js console.log('hello world'); ``` ``` **Output**: - List - with - code block: ```js console.log('hello world'); ``` ## Example with a blank line **Source**: ```md - List - with - code block: ```js console.log('hello world'); ``` ``` **Output**: - List - with - code block: ```js console.log('hello world'); ``` --- I'd appreciate if there was a way to disable MD031 for lists.
kerem 2026-03-07 20:03:46 +03:00
Author
Owner

@DavidAnson commented on GitHub (Jun 16, 2019):

Good idea!

<!-- gh-comment-id:502465946 --> @DavidAnson commented on GitHub (Jun 16, 2019): Good idea!
Author
Owner

@borekb commented on GitHub (Sep 5, 2019):

Thanks for implementing this! For anyone reading this, since 0.16.0, this config resolves it:

{
  "MD031": { "list_items": false }
}

See github.com/DavidAnson/markdownlint@c5b74d22b9.

<!-- gh-comment-id:528376033 --> @borekb commented on GitHub (Sep 5, 2019): Thanks for implementing this! For anyone reading this, since 0.16.0, this config resolves it: ```json { "MD031": { "list_items": false } } ``` See https://github.com/DavidAnson/markdownlint/commit/c5b74d22b932c6be5605219af0069255f0adaa39.
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#2021
No description provided.