markup icon indicating copy to clipboard operation
markup copied to clipboard

List not rendered to specification

Open MDeiml opened this issue 4 years ago • 0 comments

I hope this is the right place to ask this question.

A user of a treesitter grammar I wrote encountered this example

1. a
  1. b
    1. c
    2. d
      1. e
      2. f

Rendered:

  1. a
  2. b 1. c 2. d
    1. e
    2. f

which I think is not rendered to spec on github. The reference implementation on https://spec.commonmark.org/dingus/ agrees with me that c and d should not be parsed as list items. I gave an explanation in https://github.com/MDeiml/tree-sitter-markdown/issues/27 but I'll give some extra detail here.

The relevant sections in the gfm spec are:

  1. Contents of list items have to be indented at least as much as the first line (see https://github.github.com/gfm/#example-273)
  2. List items can not be indented more than 3 spaces (see https://github.github.com/gfm/#example-267)
  3. Indented code blocks cannot interrupt paragraphs (see https://github.github.com/gfm/#example-83)

The implementation on github seems to interpret 2. as that everything can be a list item but interpretation as an indented code block takes precedence. The relevant part in the spec that disagrees with that is

Indentation. If a sequence of lines Ls constitutes a list item according to rule 1, 2 or 3, then the result of indenting each line of Ls by 1-3 spaces (the same for each line) also constitutes a list item with the same contents and attributes. If a line is empty, then it need not be indented.

What do people here think about this?

MDeiml avatar Jan 13 '22 19:01 MDeiml