summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/blocks.c24
-rw-r--r--test/spec.txt32
2 files changed, 47 insertions, 9 deletions
diff --git a/src/blocks.c b/src/blocks.c
index a5e667e..7627f6e 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -388,6 +388,7 @@ static bufsize_t parse_list_marker(cmark_mem *mem, cmark_chunk *input,
unsigned char c;
bufsize_t startpos;
cmark_list *data;
+ bufsize_t i;
startpos = pos;
c = peek_at(input, pos);
@@ -397,6 +398,18 @@ static bufsize_t parse_list_marker(cmark_mem *mem, cmark_chunk *input,
if (!cmark_isspace(peek_at(input, pos))) {
return 0;
}
+
+ if (interrupts_paragraph) {
+ i = pos;
+ // require non-blank content after list marker:
+ while (S_is_space_or_tab(peek_at(input, i))) {
+ i++;
+ }
+ if (peek_at(input, i) == '\n') {
+ return 0;
+ }
+ }
+
data = (cmark_list *)mem->calloc(1, sizeof(*data));
data->marker_offset = 0; // will be adjusted later
data->list_type = CMARK_BULLET_LIST;
@@ -426,6 +439,17 @@ static bufsize_t parse_list_marker(cmark_mem *mem, cmark_chunk *input,
if (!cmark_isspace(peek_at(input, pos))) {
return 0;
}
+ if (interrupts_paragraph) {
+ // require non-blank content after list marker:
+ i = pos;
+ while (S_is_space_or_tab(peek_at(input, i))) {
+ i++;
+ }
+ if (S_is_line_end_char(peek_at(input, i))) {
+ return 0;
+ }
+ }
+
data = (cmark_list *)mem->calloc(1, sizeof(*data));
data->marker_offset = 0; // will be adjusted later
data->list_type = CMARK_ORDERED_LIST;
diff --git a/test/spec.txt b/test/spec.txt
index 6a7c658..4c3de7a 100644
--- a/test/spec.txt
+++ b/test/spec.txt
@@ -3621,17 +3621,19 @@ An [ordered list marker](@)
is a sequence of 1--9 arabic digits (`0-9`), followed by either a
`.` character or a `)` character. (The reason for the length
limit is that with 10 digits we start seeing integer overflows
-in some browsers.) Exception: In cases where ordered list markers
-interrupt paragraphs---that is, when they occur on a line
-that would otherwise count as [paragraph continuation
-text]---only `1.` and `1)` are allowed.
+in some browsers.) Exception: In cases where ordered list
+markers interrupt paragraphs---that is, when they occur on a
+line that would otherwise count as [paragraph continuation
+text]---list markers must be followed by some content other than
+spaces before the end of the line, and for ordered list markers,
+only `1.` and `1)` are allowed.
The following rules define [list items]:
1. **Basic case.** If a sequence of lines *Ls* constitute a sequence of
blocks *Bs* starting with a [non-whitespace character] and not separated
from each other by more than one blank line, and *M* is a list
- marker of width *W* followed by 0 < *N* < 5 spaces, then the result
+ marker of width *W* followed by 1 ≤ *N* ≤ 4 spaces, then the result
of prepending *M* and the following spaces to the first line of
*Ls*, and indenting subsequent lines of *Ls* by *W + N* spaces, is a
list item with *Bs* as its contents. The type of the list item
@@ -4207,6 +4209,20 @@ A list may start or end with an empty list item:
</ul>
````````````````````````````````
+However, an empty list item cannot interrupt a paragraph:
+
+```````````````````````````````` example
+foo
+*
+
+foo
+1.
+.
+<p>foo
+*</p>
+<p>foo
+1.</p>
+````````````````````````````````
4. **Indentation.** If a sequence of lines *Ls* constitutes a list item
@@ -6122,10 +6138,8 @@ A newline also counts as whitespace:
*foo bar
*
.
-<p>*foo bar</p>
-<ul>
-<li></li>
-</ul>
+<p>*foo bar
+*</p>
````````````````````````````````