cmark

My personal build of CMark ✏️

Commit
4f24c5e65ad4f7f34acf620008b5f824a81f091d
Parent
2791ffabfc7da2e19e6c5486070ebff20e9ac9df
Author
John MacFarlane <jgm@berkeley.edu>
Date

commonmark - improved tight list rendering.

Diffstat

1 file changed, 8 insertions, 11 deletions

Status File Name N° Changes Insertions Deletions
Modified src/commonmark.c 19 8 11
diff --git a/src/commonmark.c b/src/commonmark.c
@@ -39,13 +39,6 @@ static inline void blankline(struct render_state *state)
 	}
 }
 
-static inline void double_blankline(struct render_state *state)
-{
-	if (state->need_cr < 3) {
-		state->need_cr = 3;
-	}
-}
-
 typedef enum  {
 	LITERAL,
 	NORMAL,
@@ -258,8 +251,10 @@ S_render_node(cmark_node *node, cmark_event_type ev_type,
 	int marker_width;
 
 	state->in_tight_list_item =
-		node->type == CMARK_NODE_ITEM &&
-		cmark_node_get_list_tight(node->parent);
+		(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:
@@ -283,8 +278,10 @@ S_render_node(cmark_node *node, cmark_event_type ev_type,
 		if (!entering && node->next &&
 		    (node->next->type == CMARK_NODE_CODE_BLOCK ||
 		     node->next->type == CMARK_NODE_LIST)) {
-			// two blank lines after list before code block or list
-			double_blankline(state);
+			// this ensures 2 blank lines after list,
+			// if before code block or list:
+			lit(state, "\n", false);
+			state->need_cr = 0;
 		}
 		break;