markdownlint icon indicating copy to clipboard operation
markdownlint copied to clipboard

MD007: Allow several values for `start_indent`

Open skwde opened this issue 11 months ago • 2 comments

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.

skwde avatar Sep 14 '23 14:09 skwde

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

DavidAnson avatar Sep 14 '23 16:09 DavidAnson

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?!

skwde avatar Sep 15 '23 05:09 skwde