[GH-ISSUE #973] MD007: Allow several values for start_indent #577

Open
opened 2026-03-03 01:28:10 +03:00 by kerem · 2 comments
Owner

Originally created by @skwde on GitHub (Sep 14, 2023).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/973

Here are the relevant .markdownlint.yaml settings

# MD004/ul-style - Unordered list style
MD004:
  # List style
  style: sublist

# MD007/ul-indent - Unordered list indentation
MD007:
  # Spaces for indent
  indent: 4
  # Whether to indent the first level of the list
  # start_indented: true
  # Spaces for first level indent (when start_indented is set)
  # start_indent: 0

# MD010/no-hard-tabs - Hard tabs
MD010:
  # Include code blocks
  code_blocks: true
  # Number of spaces for each hard tab
  spaces_per_tab: 4

# Disable line length check for tables and code blocks
# MD013/line-length - Line length
MD013:
  # Include code blocks
  code_blocks: false
  # Include tables
  tables: false

# MD029/ol-prefix - Ordered list item prefix
MD029:
  # List style
  style: ordered

This might be related to https://github.com/DavidAnson/markdownlint/issues/284.
The following markdown

1. example1

    - sub 11
    - sub 12

2. example

    - sub 21
    - sub 22

is formatted to

1.  example1

    +   sub 11
    +   sub 12

2.  example

    +   sub 21
    +   sub 22

because the ul is thought to be at level two, but the actual ul level is 1, just appears under an ol.
If we can specify

Another use case are configuration possibilities when using the plugins for admonitions or content tabs (Both are fairly popular for the commonly used mkdocs material theme for documentation.
markdown-it-admon support for admonitions is added (somehow related https://github.com/DavidAnson/vscode-markdownlint/issues/302 at least for me :)).

However than problems arise with

this is normal list

-   cde
    +   cde

now an admonition follows

!!! note "abc"

    abc

    -   cde
 

Similarly if the proposed rule of https://github.com/DavidAnson/markdownlint/issues/138 is implemented it is also important there.

Originally created by @skwde on GitHub (Sep 14, 2023). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/973 Here are the relevant `.markdownlint.yaml` settings ```yaml # MD004/ul-style - Unordered list style MD004: # List style style: sublist # MD007/ul-indent - Unordered list indentation MD007: # Spaces for indent indent: 4 # Whether to indent the first level of the list # start_indented: true # Spaces for first level indent (when start_indented is set) # start_indent: 0 # MD010/no-hard-tabs - Hard tabs MD010: # Include code blocks code_blocks: true # Number of spaces for each hard tab spaces_per_tab: 4 # Disable line length check for tables and code blocks # MD013/line-length - Line length MD013: # Include code blocks code_blocks: false # Include tables tables: false # MD029/ol-prefix - Ordered list item prefix MD029: # List style style: ordered ``` This might be related to <https://github.com/DavidAnson/markdownlint/issues/284>. The following markdown ```markdown 1. example1 - sub 11 - sub 12 2. example - sub 21 - sub 22 ``` is formatted to ```markdown 1. example1 + sub 11 + sub 12 2. example + sub 21 + sub 22 ``` because the `ul` is thought to be at level two, but the actual `ul` level is 1, just appears under an `ol`. If we can specify Another use case are configuration possibilities when using the plugins for admonitions or content tabs (Both are fairly popular for the commonly used mkdocs material theme for documentation. `markdown-it-admon` support for admonitions is added (somehow related <https://github.com/DavidAnson/vscode-markdownlint/issues/302> at least for me :)). However than problems arise with ```markdown this is normal list - cde + cde now an admonition follows !!! note "abc" abc - cde ``` Similarly if the proposed rule of <https://github.com/DavidAnson/markdownlint/issues/138> is implemented it is also important there.
Author
Owner

@DavidAnson commented on GitHub (Sep 14, 2023):

The existing issues you've linked to seem to cover most of what you describe here. What is new or unique for this issue?

<!-- gh-comment-id:1719785483 --> @DavidAnson commented on GitHub (Sep 14, 2023): The existing issues you've linked to seem to cover most of what you describe here. What is new or unique for this issue?
Author
Owner

@skwde commented on GitHub (Sep 15, 2023):

To my understanding https://github.com/DavidAnson/markdownlint/issues/284 only asks for a check on the correct number of spaces?! I linked it because I though required changes are similiar?!

Whereas I asked for the possibility to allow ul to start at multiples of start_indent.

Here are some examples demonstrating what I ask for.
With

MD007:
  # Spaces for indent
  indent: 4

we only allow lists to start at the beginning of the line, e.g.

-   cde
    +   cde

While with

MD007:
  # Spaces for indent
  indent: 4
  # Whether to indent the first level of the list
  start_indented: true
  # Spaces for first level indent (when start_indented is set)
  start_indent: 2

we allow

  -   cde
      +   cde

but not the example starting at the beginning of the line.

With a setting allow_multiple_start (or similar):

MD007:
  # Spaces for indent
  indent: 4
  # new option
  allow_multiple_starts: [0,4,8]

we would be more flexible.

Moreover, as I mentioned in the issue description, with the config I posted, the ul list inside the ol is recognized to start at level 2 ul list and formatted accordingly (starting it with a + instead a -). In my mind that's unexpected behavior?!

<!-- gh-comment-id:1720693710 --> @skwde commented on GitHub (Sep 15, 2023): To my understanding <https://github.com/DavidAnson/markdownlint/issues/284> only asks for a check on the correct number of spaces?! I linked it because I though required changes are similiar?! Whereas I asked for the possibility to allow `ul` to start at multiples of `start_indent`. Here are some examples demonstrating what I ask for. With ```yml MD007: # Spaces for indent indent: 4 ``` we only allow lists to start at the beginning of the line, e.g. ```markdown - cde + cde ``` While with ```yaml MD007: # Spaces for indent indent: 4 # Whether to indent the first level of the list start_indented: true # Spaces for first level indent (when start_indented is set) start_indent: 2 ``` we allow ```markdown - cde + cde ``` but not the example starting at the beginning of the line. With a setting `allow_multiple_start` (or similar): ```yml MD007: # Spaces for indent indent: 4 # new option allow_multiple_starts: [0,4,8] ``` we would be more flexible. Moreover, as I mentioned in the issue description, with the config I posted, the `ul` list inside the `ol` is recognized to start at level 2 `ul` list and formatted accordingly (starting it with a `+` instead a `-`). In my mind that's unexpected behavior?!
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#577
No description provided.