summaryrefslogtreecommitdiff
path: root/src/cmark.c
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2014-11-11 12:00:42 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2014-11-11 12:01:00 -0800
commitcb744bd09103321b18ee979edac2cb26a414f7be (patch)
tree6a6837df1271598bf8bb056b03f1c41aa8195ffb /src/cmark.c
parentf8d804300a134993a667ecf66063ee15accc6712 (diff)
Added cmark_markdown_to_html with a simple interface.
See #70.
Diffstat (limited to 'src/cmark.c')
-rw-r--r--src/cmark.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cmark.c b/src/cmark.c
new file mode 100644
index 0000000..064c080
--- /dev/null
+++ b/src/cmark.c
@@ -0,0 +1,19 @@
+#include <stdlib.h>
+#include <assert.h>
+#include <stdio.h>
+
+#include "cmark.h"
+#include "buffer.h"
+
+extern unsigned char *cmark_markdown_to_html(unsigned char *text)
+{
+ node_block *blocks;
+ strbuf htmlbuf = GH_BUF_INIT;
+
+ blocks = cmark_parse_document(text, sizeof(text));
+
+ cmark_render_html(&htmlbuf, blocks);
+ cmark_free_nodes(blocks);
+
+ return strbuf_detach(&htmlbuf);
+}