cmark

My personal build of CMark ✏️

Commit
318aa82f73448275f4653b18e7d154782aa220c5
Parent
14b997d9350b3ee3f6d67fb12b470bf406d4a31b
Author
John MacFarlane <jgm@berkeley.edu>
Date

Readjust parser->current after closing fenced block.

Added assertion to raise an error if finalize is called on a closed block (as was happening undetected because of the fallback behavior).

Diffstat

1 file changed, 2 insertions, 5 deletions

Status File Name N° Changes Insertions Deletions
Modified src/blocks.c 7 2 5
diff --git a/src/blocks.c b/src/blocks.c
@@ -192,10 +192,7 @@ finalize(cmark_parser *parser, cmark_node* b)
 
 	parent = b->parent;
 
-	// don't do anything if the cmark_node is already closed
-	if (!b->open)
-		return parent;
-
+	assert(b->open);  // shouldn't call finalize on closed blocks
 	b->open = false;
 
 	if (parser->curline->size == 0) {
@@ -605,7 +602,7 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
 					// the end of a line, we can return:
 					all_matched = false;
 					offset += matched;
-					finalize(parser, container);
+					parser->current = finalize(parser, container);
 					goto finished;
 				} else {
 					// skip opt. spaces of fence offset