diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2014-11-16 10:45:50 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2014-11-16 10:45:50 -0800 |
commit | 5a26ca5cf9481289ad77d6049b55c48feea7cc38 (patch) | |
tree | 561595c5de9009425a168a39d9f4f3060b82183d | |
parent | b7f6e3f775705029df262aa313a0cd17ee3073cb (diff) |
cmark_render_html now just returns a regular C string.
This way, we don't have to expose buffer.h; it is just used
internally.
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/cmark.c | 6 | ||||
-rw-r--r-- | src/cmark.h | 3 | ||||
-rw-r--r-- | src/html/html.c | 10 | ||||
-rw-r--r-- | src/main.c | 7 |
5 files changed, 12 insertions, 16 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2413acd..7da839f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -89,7 +89,7 @@ install(TARGETS ${PROGRAM} ${LIBRARY} LIBRARY DESTINATION lib ) -install(FILES cmark.h buffer.h chunk.h references.h ${CMAKE_CURRENT_BINARY_DIR}/cmark_export.h +install(FILES cmark.h chunk.h ${CMAKE_CURRENT_BINARY_DIR}/cmark_export.h DESTINATION include/${PROJECT_NAME} ) diff --git a/src/cmark.c b/src/cmark.c index 85e1adb..96b3080 100644 --- a/src/cmark.c +++ b/src/cmark.c @@ -11,17 +11,13 @@ unsigned char *cmark_markdown_to_html(unsigned char *text, int len) { node_block *blocks; - strbuf htmlbuf = GH_BUF_INIT; unsigned char *result; blocks = cmark_parse_document(text, len); - cmark_render_html(&htmlbuf, blocks); + result = cmark_render_html(blocks); cmark_free_blocks(blocks); - result = strbuf_detach(&htmlbuf); - strbuf_free(&htmlbuf); - return result; } diff --git a/src/cmark.h b/src/cmark.h index e28e747..3dfb2de 100644 --- a/src/cmark.h +++ b/src/cmark.h @@ -3,7 +3,6 @@ #include <stdbool.h> #include <stdio.h> -#include "buffer.h" #include "chunk.h" #ifdef __cplusplus @@ -43,7 +42,7 @@ CMARK_EXPORT void cmark_debug_print(cmark_node_block *root); CMARK_EXPORT -void cmark_render_html(cmark_strbuf *html, cmark_node_block *root); +unsigned char *cmark_render_html(cmark_node_block *root); CMARK_EXPORT unsigned char *cmark_markdown_to_html(unsigned char *text, int len); diff --git a/src/html/html.c b/src/html/html.c index cd02f83..faa570b 100644 --- a/src/html/html.c +++ b/src/html/html.c @@ -5,6 +5,7 @@ #include <assert.h> #include "cmark.h" +#include "buffer.h" #include "ast.h" #include "debug.h" #include "html/houdini.h" @@ -373,7 +374,12 @@ static void blocks_to_html(strbuf *html, node_block *b) free_render_stack(rstack); } -extern void cmark_render_html(strbuf *html, node_block *root) +unsigned char *cmark_render_html(node_block *root) { - blocks_to_html(html, root); + unsigned char *result; + strbuf html = GH_BUF_INIT; + blocks_to_html(&html, root); + result = strbuf_detach(&html); + strbuf_free(&html); + return result; } @@ -3,7 +3,6 @@ #include <string.h> #include <errno.h> #include "cmark.h" -#include "buffer.h" #include "debug.h" #include "bench.h" @@ -17,14 +16,10 @@ void print_usage() static void print_document(node_block *document, bool ast) { - strbuf html = GH_BUF_INIT; - if (ast) { cmark_debug_print(document); } else { - cmark_render_html(&html, document); - printf("%s", html.ptr); - strbuf_free(&html); + printf("%s", cmark_render_html(document)); } } |