# Odd List behaviour?

**URL:** <https://talk.commonmark.org/t/odd-list-behaviour/1189>\
**Category:** Spec\
**Created:** [May 22, 2015, 7:29am UTC](https://talk.commonmark.org/t/odd-list-behaviour/1189 "2015-05-22T07:29:36Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_LeBeau](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/paul_lebeau/32/698_2.png) [@Paul\_LeBeau](https://talk.commonmark.org/u/Paul_LeBeau)\
**Post date:** [May 22, 2015, 7:29am UTC](https://talk.commonmark.org/t/odd-list-behaviour/1189/1 "2015-05-22T07:29:37Z")

</div>

Here’s a markdown puzzle for everyone… It’s an extended version of Example 213 in the spec.

What would be the expected result of the following sample?

```auto
1. zero
 1. one
  1. two
   1. three
    1. four
     1. five
      1. six
       1. seven
        1. eight
         1. nine
          1. ten

```

and would you expect the following to render differently?

```auto
100. zero
 1. one
  1. two
   1. three
    1. four
     1. five
      1. six
       1. seven
        1. eight
         1. nine
          1. ten

```

Here are the dingus links so you can test if you were right 😄

[Sample 1](http://spec.commonmark.org/dingus/?text=1.%20zero%0A%201.%20one%0A%20%201.%20two%0A%20%20%201.%20three%0A%20%20%20%201.%20four%0A%20%20%20%20%201.%20five%0A%20%20%20%20%20%201.%20six%0A%20%20%20%20%20%20%201.%20seven%0A%20%20%20%20%20%20%20%201.%20eight%0A%20%20%20%20%20%20%20%20%201.%20nine%0A%20%20%20%20%20%20%20%20%20%201.%20ten%0A)

[Sample 2](http://spec.commonmark.org/dingus/?text=100.%20zero%0A%201.%20one%0A%20%201.%20two%0A%20%20%201.%20three%0A%20%20%20%201.%20four%0A%20%20%20%20%201.%20five%0A%20%20%20%20%20%201.%20six%0A%20%20%20%20%20%20%201.%20seven%0A%20%20%20%20%20%20%20%201.%20eight%0A%20%20%20%20%20%20%20%20%201.%20nine%0A%20%20%20%20%20%20%20%20%20%201.%20ten%0A)

The behaviour seems odd to me, and the result is complete different in commonmark.js compared to others like [markdown.pl](http://markdown.pl) and GFM. But I am having trouble working out whether that is due to a bug in commonmark.js, or whether I am just not understanding the spec properly.

Based on the text above examples 197 and 213, I would have expected Sample 1 to be rendered

```auto
 1. zero
 2. one
 3. two
 4. three
 5. four
 6. five
 7. six
 8. seven
 9. eight
10. nine
11. ten

```

since none of the lines is indented enough to become a sublist. The “four” line is being treated as a continuation. But I am not sure why that is the case.

So, is this a bug, or a spec issue, or BKAC issue?

Thanks.

---

<div class="post-metadata">

**Author:** ![lu\_zero](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/lu_zero/32/557_2.png) [@lu\_zero](https://talk.commonmark.org/u/lu_zero)\
**Post date:** [May 22, 2015, 9:52am UTC](https://talk.commonmark.org/t/odd-list-behaviour/1189/2 "2015-05-22T09:52:27Z")

</div>

Looks like a bug with 4[space] causing the problem

---

<div class="post-metadata">

**Author:** ![jgm](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/jgm/32/1360_2.png) [@jgm](https://talk.commonmark.org/u/jgm)\
**Post date:** [May 26, 2015, 6:25am UTC](https://talk.commonmark.org/t/odd-list-behaviour/1189/3 "2015-05-26T06:25:31Z")

</div>

If you read the spec on lists, you’ll see why this gives you the  
behavior it does with the reference implementations.

Block-level content inside list items (including other lists) need to be  
indented past the list marker. In this case the marker is two  
characters wide, so you need at least two spaces indent (not just one)  
to get a sublist. For bullet lists, the marker is one space wide, so  
one space indent suffices.

---

<div class="post-metadata">

**Author:** ![Paul\_LeBeau](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/paul_lebeau/32/698_2.png) [@Paul\_LeBeau](https://talk.commonmark.org/u/Paul_LeBeau)\
**Post date:** [May 26, 2015, 2:13pm UTC](https://talk.commonmark.org/t/odd-list-behaviour/1189/4 "2015-05-26T14:13:30Z")

</div>

I have read the list section numerous times. It has so far been the hardest part of the spec to follow.

In any case Example 213 states:

> List items need not be indented to the same level. The following list items will be treated as items at the same list level, since none is indented enough to belong to the previous list item:

But if that’s the case, why is my example any different from Example 213? None of these are indented enough to belong to the previous list item either.

Which part of the spec is coming into effect to override this behaviour?

---

<div class="post-metadata">

**Author:** ![jgm](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/jgm/32/1360_2.png) [@jgm](https://talk.commonmark.org/u/jgm)\
**Post date:** [May 27, 2015, 9:02pm UTC](https://talk.commonmark.org/t/odd-list-behaviour/1189/5 "2015-05-27T21:02:10Z")

</div>

Sorry, I replied before properly appreciating your point. This is indeed puzzling! I’ll need to look into this more when I get some time; most likely it’s a bug in the implementations.

---

<div class="post-metadata">

**Author:** ![jgm](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/jgm/32/1360_2.png) [@jgm](https://talk.commonmark.org/u/jgm)\
**Post date:** [May 27, 2015, 9:22pm UTC](https://talk.commonmark.org/t/odd-list-behaviour/1189/6 "2015-05-27T21:22:22Z")

</div>

Here’s another simple case:

```auto
10000. ok
    1. ok

```

which yields

```auto
<ol start="10000">
<li>ok
1. ok</li>
</ol>

```

---

<div class="post-metadata">

**Author:** ![jgm](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/jgm/32/1360_2.png) [@jgm](https://talk.commonmark.org/u/jgm)\
**Post date:** [May 27, 2015, 9:42pm UTC](https://talk.commonmark.org/t/odd-list-behaviour/1189/7 "2015-05-27T21:42:29Z")

</div>

Another case:

```auto
   10. hi
    11. there

```

```auto
<ol start="10">
<li>hi
11. there</li>
</ol>

```

@lu_zero is right that the trigger is a four-space indent.

---

<div class="post-metadata">

**Author:** ![jgm](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/jgm/32/1360_2.png) [@jgm](https://talk.commonmark.org/u/jgm)\
**Post date:** [May 27, 2015, 10:15pm UTC](https://talk.commonmark.org/t/odd-list-behaviour/1189/8 "2015-05-27T22:15:29Z")

</div>

OK, I see what is going on here. In `lib/blocks.js`, around lines 384-399, the parser assumes that if a line is indented 4 or more spaces but it’s not a code block (because it would be interrupting a paragraph), then it’s a lazy paragraph continuation. That assumption is wrong, because it might be a list item.

---

<div class="post-metadata">

**Author:** ![lu\_zero](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/lu_zero/32/557_2.png) [@lu\_zero](https://talk.commonmark.org/u/lu_zero)\
**Post date:** [May 28, 2015, 6:11pm UTC](https://talk.commonmark.org/t/odd-list-behaviour/1189/9 "2015-05-28T18:11:07Z")

</div>

I pushed a [workaround](https://github.com/lu-zero/CommonMark-py/commit/76f4d77ae560c9d3eae31feb2ceb9168e3fd02e4) for CommonMark-py to see if that was the problem and seems working up to a point.

---

<div class="post-metadata">

**Author:** ![jgm](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/jgm/32/1360_2.png) [@jgm](https://talk.commonmark.org/u/jgm)\
**Post date:** [June 3, 2015, 9:10am UTC](https://talk.commonmark.org/t/odd-list-behaviour/1189/10 "2015-06-03T09:10:44Z")

</div>

I’ve fixed this in both cmark and commonmark.js, and added a test case in the spec.

---

<div class="post-metadata">

**Author:** ![lu\_zero](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/lu_zero/32/557_2.png) [@lu\_zero](https://talk.commonmark.org/u/lu_zero)\
**Post date:** [June 3, 2015, 9:26am UTC](https://talk.commonmark.org/t/odd-list-behaviour/1189/11 "2015-06-03T09:26:28Z")

</div>

Thanks @jgm ! I’ll have a look to try to keep the pure-python implementation in sync soon.

---

<div class="post-metadata">

**Author:** ![raph](https://cdn.commonmark.org/letter_avatar_proxy/v2/letter/r/e8c25b/32.png) [@raph](https://talk.commonmark.org/u/raph)\
**Post date:** [June 5, 2015, 4:33pm UTC](https://talk.commonmark.org/t/odd-list-behaviour/1189/12 "2015-06-05T16:33:41Z")

</div>

I do think the new behavior is more intuitive, but I’m still struggling to understand the spec. I looked at the implementation, and see it’s based on whether a line can be lazily continued, but I’m not yet 100% convinced this is the correct formulation. For one, making the list loose brings you back to interpreting the inner indents as a code block. Simple test case:

```
- a

   - b

      - c

```

So I definitely don’t feel that the spec language precisely specifies what an implementation should do at this point.

(Incidentally, my implementation is now open-source and it’s possible to play with it: [pulldown-cmark](https://github.com/google/pulldown-cmark). This case is currently the only test that’s failing)

---

<div class="post-metadata">

**Author:** ![lu\_zero](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/lu_zero/32/557_2.png) [@lu\_zero](https://talk.commonmark.org/u/lu_zero)\
**Post date:** [June 5, 2015, 6:41pm UTC](https://talk.commonmark.org/t/odd-list-behaviour/1189/13 "2015-06-05T18:41:17Z")

</div>

I’d consider the list item as blockquote so if

```auto
> code
> notcode

```

Is acceptable so should be

```auto
- This is a code snippet
- This is not

```

Or not?

---

<div class="post-metadata">

**Author:** ![raph](https://cdn.commonmark.org/letter_avatar_proxy/v2/letter/r/e8c25b/32.png) [@raph](https://talk.commonmark.org/u/raph)\
**Post date:** [June 9, 2015, 5:24am UTC](https://talk.commonmark.org/t/odd-list-behaviour/1189/14 "2015-06-09T05:24:58Z")

</div>

What landed in 0.20 looks fine to me. [pulldown-cmark 0.0.3](https://github.com/google/pulldown-cmark/commit/c2ef772d8264d3064cad94956d26822aa82b189b) passes all spec tests.
