Skip to content

Commit b44f479

Browse files
Also handle CMARK_NODE_HTML_BLOCK
1 parent e27a52f commit b44f479

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/blocks.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,18 @@ static void remove_trailing_blank_lines(cmark_strbuf *ln) {
259259
// Check to see if a node ends with a blank line, descending
260260
// if needed into lists and sublists.
261261
static bool S_ends_with_blank_line(cmark_node *node) {
262-
if (S_last_line_checked(node)) {
263-
return(S_last_line_blank(node));
264-
} else if ((S_type(node) == CMARK_NODE_LIST ||
265-
S_type(node) == CMARK_NODE_ITEM) && node->last_child) {
266-
S_set_last_line_checked(node);
267-
return(S_ends_with_blank_line(node->last_child));
268-
} else {
269-
S_set_last_line_checked(node);
270-
return (S_last_line_blank(node));
262+
while (true) {
263+
if (S_last_line_checked(node)) {
264+
return(S_last_line_blank(node));
265+
} else if ((S_type(node) == CMARK_NODE_LIST ||
266+
S_type(node) == CMARK_NODE_ITEM) && node->last_child) {
267+
S_set_last_line_checked(node);
268+
node = node->last_child;
269+
continue;
270+
} else {
271+
S_set_last_line_checked(node);
272+
return (S_last_line_blank(node));
273+
}
271274
}
272275
}
273276

@@ -1137,6 +1140,7 @@ static cmark_node *check_open_blocks(cmark_parser *parser, cmark_chunk *input,
11371140
// fall through
11381141
case CMARK_NODE_CODE_BLOCK:
11391142
case CMARK_NODE_PARAGRAPH:
1143+
case CMARK_NODE_HTML_BLOCK:
11401144
// Jump to parser->current
11411145
container = parser->current;
11421146
cont_type = S_type(container);

0 commit comments

Comments
 (0)