kjdev / hoextdown

Hoextdown is an extension to Hoedown
MIT License
23 stars 15 forks source link

Fenced code at start of numbered list item resets number at next item #57

Closed gagern closed 4 years ago

gagern commented 4 years ago
1. First item.

1. ```
   Some code.
   More code.

There is code here.

  1. Third item.

The code above resets item numbering for the third item. In other words, it ends one <ol> and starts another after the second item, the one starting in the code block. I could reproduce this with hoedown --fenced-code using current HEAD, namely 980b9c549b4348d50b683ecee6abee470b98acda.

https://spec.commonmark.org/0.29/#lists states that a list consists of consecutive list items of the same kind, so I believe that my expected behavior of one continued list is in line with the spec, and the implemented behavior is not. Things might be different if the There is code here line were considered to be after the list, but as it is still inside the <li> then the list item definitely gets treated as continuing till that line.

Some experiments show that having a non-code line of text at the beginning of the item fixes the renumbering issue. An empty line as the first item of the numbered list does fix this as well, but as the space after the number is part of the list marker, that means a trailing space in the line with the number. I have written down these cases and the resulting Hoedown rendering in a gist.

I found that this issue is also present in Hoedown, and I filed https://github.com/hoedown/hoedown/issues/236 for that. I'm wondering whether https://github.com/kjdev/hoextdown/issues/6 might be related as well.