summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-03-29 18:05:55 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-03-29 18:05:55 -0700
commit86263adc7ee25ca727c770586fe1a67e41ad8f10 (patch)
tree45b90878bc72da1bb6c60819243975bc39a26d81
parent1fad45bf96b3daf2fcba747d44caa4556c68917a (diff)
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.
-rw-r--r--src/commonmark.c16
1 files changed, 11 insertions, 5 deletions
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: