diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-07-05 16:20:34 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-07-11 22:23:45 +0100 |
commit | d534f7e1f398311f20303664415ea0ae0f50a8a2 (patch) | |
tree | ed40a2706268875196fee1217598b276853d3fd9 /src | |
parent | ff9fad1d4ba8368bc9b5dccbfb442224a1d571a3 (diff) |
Don't allow ordered lists to interrupt paragraphs unless...
...they start with 1.
Diffstat (limited to 'src')
-rw-r--r-- | src/blocks.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/blocks.c b/src/blocks.c index b21f800..2cd2ec8 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -401,7 +401,8 @@ static void process_inlines(cmark_mem *mem, cmark_node *root, // On success, returns length of the marker, and populates // data with the details. On failure, returns 0. static bufsize_t parse_list_marker(cmark_mem *mem, cmark_chunk *input, - bufsize_t pos, cmark_list **dataptr) { + bufsize_t pos, bool interrupts_paragraph, + cmark_list **dataptr) { unsigned char c; bufsize_t startpos; cmark_list *data; @@ -434,6 +435,9 @@ static bufsize_t parse_list_marker(cmark_mem *mem, cmark_chunk *input, // This also seems to be the limit for 'start' in some browsers. } while (digits < 9 && cmark_isdigit(peek_at(input, pos))); + if (interrupts_paragraph && start != 1) { + return 0; + } c = peek_at(input, pos); if (c == '.' || c == ')') { pos++; @@ -921,8 +925,12 @@ static void open_new_blocks(cmark_parser *parser, cmark_node **container, parser->first_nonspace + 1); S_advance_offset(parser, input, input->len - 1 - parser->offset, false); } else if ((matched = parse_list_marker(parser->mem, input, - parser->first_nonspace, &data)) && - (!indented || cont_type == CMARK_NODE_LIST)) { + parser->first_nonspace, + (*container)->type == + CMARK_NODE_PARAGRAPH, + &data)) && + (!indented || cont_type == CMARK_NODE_LIST)) { + // Note that we can have new list items starting with >= 4 // spaces indent, as long as the list container is still open. int i = 0; |