summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commonmark.c3
-rw-r--r--src/latex.c3
-rw-r--r--src/render.c5
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);