cmark

My personal build of CMark ✏️

Commit
86263adc7ee25ca727c770586fe1a67e41ad8f10
Parent
1fad45bf96b3daf2fcba747d44caa4556c68917a
Author
John MacFarlane <jgm@berkeley.edu>
Date

commonmark writer - more tight list fixes.

Avoid losing blank line *before* a tight list, by adjusting `state->in_tight_list_item` only *after* we've started the first list item.

Diffstat

1 file changed, 11 insertions, 5 deletions

Status File Name N° Changes Insertions Deletions
Modified src/commonmark.c 16 11 5
diff --git a/src/commonmark.c b/src/commonmark.c
@@ -250,11 +250,17 @@ S_render_node(cmark_node *node, cmark_event_type ev_type,
 	char *emph_delim;
 	int marker_width;
 
-	state->in_tight_list_item =
-		(node->type == CMARK_NODE_ITEM &&
-		 cmark_node_get_list_tight(node->parent)) ||
-		(node->parent && node->parent->type == CMARK_NODE_ITEM &&
-		 cmark_node_get_list_tight(node->parent->parent));
+	// Don't adjust tight list status til we've started the list.
+	// Otherwise we loose the blank line between a paragraph and
+	// a following list.
+	if (!(node->type == CMARK_NODE_ITEM && node->prev == NULL &&
+	      entering)) {
+		state->in_tight_list_item =
+			(node->type == CMARK_NODE_ITEM &&
+			 cmark_node_get_list_tight(node->parent)) ||
+			(node->parent && node->parent->type == CMARK_NODE_ITEM &&
+			 cmark_node_get_list_tight(node->parent->parent));
+	}
 
 	switch (node->type) {
 	case CMARK_NODE_DOCUMENT: