From 86263adc7ee25ca727c770586fe1a67e41ad8f10 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 29 Mar 2015 18:05:55 -0700 Subject: 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. --- src/commonmark.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/commonmark.c') diff --git a/src/commonmark.c b/src/commonmark.c index 96f4c3a..c94cf9a 100644 --- 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: -- cgit v1.2.3