diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-07-12 13:46:35 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-07-12 13:46:35 -0700 |
commit | 6ecd359a195d3dce3c093cc955936e4ed954b48d (patch) | |
tree | ae859726c27619330143bab587ab473042772cf0 | |
parent | d64b1d286960ddf59df8dda9ab749b27a72ed6d1 (diff) |
cmark_render: ensure final newline.
This allows us to remove direct manipulation of buffer from
the latex and commonmark renderers.
-rw-r--r-- | src/commonmark.c | 3 | ||||
-rw-r--r-- | src/latex.c | 3 | ||||
-rw-r--r-- | src/render.c | 5 |
3 files changed, 5 insertions, 6 deletions
diff --git a/src/commonmark.c b/src/commonmark.c index 44f8788..09644a0 100644 --- a/src/commonmark.c +++ b/src/commonmark.c @@ -195,9 +195,6 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, switch (node->type) { case CMARK_NODE_DOCUMENT: - if (!entering) { - cmark_strbuf_putc(renderer->buffer, '\n'); - } break; case CMARK_NODE_BLOCK_QUOTE: diff --git a/src/latex.c b/src/latex.c index 058f212..684c855 100644 --- a/src/latex.c +++ b/src/latex.c @@ -285,9 +285,6 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, switch (node->type) { case CMARK_NODE_DOCUMENT: - if (!entering) { - cmark_strbuf_putc(renderer->buffer, '\n'); - } break; case CMARK_NODE_BLOCK_QUOTE: diff --git a/src/render.c b/src/render.c index 16caadc..f60835f 100644 --- a/src/render.c +++ b/src/render.c @@ -154,6 +154,11 @@ cmark_render(cmark_node *root, } } + // ensure final newline + if (renderer.buffer->ptr[renderer.buffer->size - 1] != '\n') { + cmark_strbuf_putc(renderer.buffer, '\n'); + } + result = (char *)cmark_strbuf_detach(renderer.buffer); cmark_iter_free(iter); |