diff options
-rw-r--r-- | src/cmark.h | 2 | ||||
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/print.c | 7 |
3 files changed, 9 insertions, 6 deletions
diff --git a/src/cmark.h b/src/cmark.h index d778a53..6105332 100644 --- a/src/cmark.h +++ b/src/cmark.h @@ -185,7 +185,7 @@ cmark_node *cmark_parse_file(FILE *f); // Renderer CMARK_EXPORT -void cmark_debug_print(cmark_node *root); +char *cmark_render_ast(cmark_node *root); CMARK_EXPORT char *cmark_render_html(cmark_node *root); @@ -19,13 +19,13 @@ static void print_document(cmark_node *document, bool ast) { char *result; if (ast) { - cmark_debug_print(document); + result = cmark_render_ast(document); } else { result = cmark_render_html(document); - printf("%s", result); - free(result); } + printf("%s", result); + free(result); } int main(int argc, char *argv[]) diff --git a/src/print.c b/src/print.c index 9f1f233..d2dfe8c 100644 --- a/src/print.c +++ b/src/print.c @@ -158,9 +158,12 @@ static void render_nodes(strbuf* buffer, cmark_node* node, int indent) } } -void cmark_debug_print(cmark_node *root) +char *cmark_render_ast(cmark_node *root) { + char* result; strbuf buffer = GH_BUF_INIT; render_nodes(&buffer, root, -2); - printf("%s", buffer.ptr); + result = (char *)strbuf_detach(&buffer); + strbuf_free(&buffer); + return result; } |