summaryrefslogtreecommitdiff
path: root/src/blocks.c
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-06-06 21:51:17 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2015-06-06 21:51:17 +0200
commit56b1123c6662169ffe6a0eabc67f8533e745eb97 (patch)
treeccc4e876495d57cf3dc09ab33b026ea74f2c1445 /src/blocks.c
parentd63dd090693f6065b7a79d634bf88e45da089b53 (diff)
Allow new list item container indented > 4 spaces.
This fixes cases like: ``` 1. a 2. b 3. c ```
Diffstat (limited to 'src/blocks.c')
-rw-r--r--src/blocks.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/blocks.c b/src/blocks.c
index 8ccaa25..d6fa552 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -696,16 +696,7 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
indented = indent >= CODE_INDENT;
blank = is_line_end_char(peek_at(&input, first_nonspace));
- if (indented && !maybe_lazy && !blank) {
- offset += CODE_INDENT;
- container = add_child(parser, container, NODE_CODE_BLOCK, offset + 1);
- container->as.code.fenced = false;
- container->as.code.fence_char = 0;
- container->as.code.fence_length = 0;
- container->as.code.fence_offset = 0;
- container->as.code.info = cmark_chunk_literal("");
-
- } else if (!indented && peek_at(&input, first_nonspace) == '>') {
+ if (!indented && peek_at(&input, first_nonspace) == '>') {
offset = first_nonspace + 1;
// optional following character
@@ -765,7 +756,10 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
container = finalize(parser, container);
offset = input.len - 1;
- } else if ((matched = parse_list_marker(&input, first_nonspace, &data))) {
+ } else if ((matched = parse_list_marker(&input, first_nonspace, &data)) &&
+ (!indented || container->type == NODE_LIST)) {
+ // Note that we can have new list items starting with >= 4
+ // spaces indent, as long as the list container is still open.
// compute padding:
offset = first_nonspace + matched;
@@ -804,6 +798,16 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
/* TODO: static */
memcpy(&container->as.list, data, sizeof(*data));
free(data);
+
+ } else if (indented && !maybe_lazy && !blank) {
+ offset += CODE_INDENT;
+ container = add_child(parser, container, NODE_CODE_BLOCK, offset + 1);
+ container->as.code.fenced = false;
+ container->as.code.fence_char = 0;
+ container->as.code.fence_length = 0;
+ container->as.code.fence_offset = 0;
+ container->as.code.info = cmark_chunk_literal("");
+
} else {
break;
}