Skip to content

Default Markdown list formatting is not spec-compliant #12110

@oliversalzburg

Description

@oliversalzburg

This issue possibly duplicates #3679 and #5019.

Prettier 2.5.1
Playground link

--parser markdown

Input:

- i like list
  - with
  - sub
  - items

1. i like list
   1. with
   1. sub
   1. items

Output:

- i like list
  - with
  - sub
  - items

1. i like list
   1. with
   1. sub
   1. items

Expected behavior:

- i like list
    - with
    - sub
    - items

1. i like list
    1. with
    1. sub
    1. items

I'm working on some documentation, which is built with MkDocs, which uses the python-markdown library, which requires list item bodies to be indented by 4 spaces, per the spec. They point to this part of the spec:

List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab

Prettiers default auto-formatting in this scenario breaks nested lists, as they are only indented with 2 spaces. I would argue, that the configured tab width in Prettier should not have an impact here, as the 4 space (or 1 tab) indentation is explicit in the spec.

To correct this behavior, I first tried to just use --tab-width=4, which fixes the MkDocs rendering of the list.

But now the output is very confusing to me. Why is there indentation added to the list item itself, but only for the unordered list? (Likely discussed in #5019) Is this a bug? Is this even the right way to resolve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions