Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gagern opened this issue Jun 22, 2020 · 0 comments · May be fixed by #237
Open

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

gagern opened this issue Jun 22, 2020 · 0 comments · May be fixed by #237

Comments

@gagern
Copy link

gagern commented Jun 22, 2020

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 980b9c5.

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'm actually experiencing this with Hoextdown, and will write a corresponding bug report there as well. Not sure how much exchange there is between these projects today.

gagern added a commit to gagern/hoedown that referenced this issue Jun 22, 2020
Prior to this change, the in_fenced flag was not set correctly for the first
line, and therefore inverted for every following line if the first line did
start with a code block. Since the start of a subsequent list item is
explicitly not detected while in fenced code, this essentially disabled the
has_next_oli detection, leading to HOEDOWN_LI_END terminating not only the
list item but the list as a whole.

Fixes hoedown#236.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant