cmark

My personal build of CMark ✏️

Commit
a47d3332c073ec3d0420d0b7947544b0f26d910f
Parent
fb737bd9dfe1aa03767fe01fc1d28ed46652158b
Author
John MacFarlane <jgm@berkeley.edu>
Date

Empty list items cannot interrupt paragraphs (spec change).

Diffstat

1 file changed, 24 insertions, 0 deletions

Status File Name N° Changes Insertions Deletions
Modified src/blocks.c 24 24 0
diff --git 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 (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_ORDERED_LIST;