diff options
| author | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-04-02 18:41:54 +0300 |
|---|---|---|
| committer | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-04-02 18:41:54 +0300 |
| commit | 3d2121f5d6555744ce5aa502088fc2b34dc26d38 (patch) | |
| tree | 53f42c08746171878b57f5b6ffe1eb841da9d45d /cmark/src/cmark.c | |
| parent | 6bf7c5ce92ff6237c0b17c332873805018812b40 (diff) | |
| parent | 64efa3b3b3d35f2ffb604b57a8a9c89047cb420b (diff) | |
| download | Project-Tick-3d2121f5d6555744ce5aa502088fc2b34dc26d38.tar.gz Project-Tick-3d2121f5d6555744ce5aa502088fc2b34dc26d38.zip | |
Add 'cmark/' from commit '64efa3b3b3d35f2ffb604b57a8a9c89047cb420b'
git-subtree-dir: cmark
git-subtree-mainline: 6bf7c5ce92ff6237c0b17c332873805018812b40
git-subtree-split: 64efa3b3b3d35f2ffb604b57a8a9c89047cb420b
Diffstat (limited to 'cmark/src/cmark.c')
| -rw-r--r-- | cmark/src/cmark.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/cmark/src/cmark.c b/cmark/src/cmark.c new file mode 100644 index 0000000000..60aedbc6f1 --- /dev/null +++ b/cmark/src/cmark.c @@ -0,0 +1,48 @@ +#include <stdlib.h> +#include <assert.h> +#include <stdio.h> +#include "node.h" +#include "houdini.h" +#include "cmark.h" +#include "buffer.h" + +int cmark_version(void) { return CMARK_VERSION; } + +const char *cmark_version_string(void) { return CMARK_VERSION_STRING; } + +static void *xcalloc(size_t nmem, size_t size) { + void *ptr = calloc(nmem, size); + if (!ptr) { + fprintf(stderr, "[cmark] calloc returned null pointer, aborting\n"); + abort(); + } + return ptr; +} + +static void *xrealloc(void *ptr, size_t size) { + void *new_ptr = realloc(ptr, size); + if (!new_ptr) { + fprintf(stderr, "[cmark] realloc returned null pointer, aborting\n"); + abort(); + } + return new_ptr; +} + +cmark_mem DEFAULT_MEM_ALLOCATOR = {xcalloc, xrealloc, free}; + +cmark_mem *cmark_get_default_mem_allocator(void) { + return &DEFAULT_MEM_ALLOCATOR; +} + + +char *cmark_markdown_to_html(const char *text, size_t len, int options) { + cmark_node *doc; + char *result; + + doc = cmark_parse_document(text, len, options); + + result = cmark_render_html(doc, options); + cmark_node_free(doc); + + return result; +} |
