diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-03-29 16:52:11 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-03-29 16:59:43 -0700 |
commit | 4f24c5e65ad4f7f34acf620008b5f824a81f091d (patch) | |
tree | 8f9895b2cb198264d9b14fe51da22ae17e2a99e1 /src | |
parent | 2791ffabfc7da2e19e6c5486070ebff20e9ac9df (diff) |
commonmark - improved tight list rendering.
Diffstat (limited to 'src')
-rw-r--r-- | src/commonmark.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/commonmark.c b/src/commonmark.c index 66d4ba7..b8ff25b 100644 --- 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; |