cmark

My personal build of CMark ✏️

Commit
029ced080c5fd483db72bba5082a16faeb8f8b75
Parent
9a1b342685243c31d986248b12d96e4cb9db589d
Author
John MacFarlane <jgm@berkeley.edu>
Date

commonmark renderer - two blank lines after list before code/list.

Diffstat

1 file changed, 13 insertions, 0 deletions

Status File Name N° Changes Insertions Deletions
Modified src/commonmark.c 13 13 0
diff --git a/src/commonmark.c b/src/commonmark.c
@@ -39,6 +39,13 @@ 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,
@@ -245,6 +252,12 @@ S_render_node(cmark_node *node, cmark_event_type ev_type,
 		break;
 
 	case CMARK_NODE_LIST:
+		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);
+		}
 		break;
 
 	case CMARK_NODE_ITEM: