Commit b55410f
authored
fix: parse empty list item with trailing space (#3984)
A bare list marker followed only by a space (e.g. `- ` or `1. `) was not
recognized as a list and fell through to a paragraph, so `- ` rendered as
`<p>- </p>` instead of an empty list item. A marker with no trailing space
(`-`, `1.`) and an empty item that continues an existing list were already
handled correctly, making the behavior inconsistent.
The block `list` rule required content after the marker's whitespace
(`[ \t][^\n]+?`), so a marker followed only by whitespace failed to match.
Relax it to `[ \t][^\n]*?` so a marker with trailing whitespace and no
content still starts a list, matching the CommonMark reference and
markdown-it.
To keep CommonMark's rule that an empty list item cannot interrupt a
paragraph, the paragraph list-interrupt patterns now require a non-blank
character after the marker, so `foo\n+ ` stays a single paragraph while
`foo\n- bar` still interrupts.1 parent c6e667b commit b55410f
3 files changed
Lines changed: 33 additions & 4 deletions
File tree
- src
- test/specs/new
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
0 commit comments