From 3e00c224007db19cdc7869435967c5decea570a5 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Fri, 1 May 2026 18:33:16 +0200 Subject: feat(lib): introduce document notion in C ABI --- examples/main.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/main.c b/examples/main.c index 5dd3a4b..18393c6 100644 --- a/examples/main.c +++ b/examples/main.c @@ -1,15 +1,25 @@ #include #include #include -#include "typdown.h" +#include void foo(char *v) { uint8_t code; - char *res = typdown_parse(v, &code); - if (code == 0) { - printf("%s\n", res); - free(res); - } else printf("cannot parse '%s', error: %s (%d)\n", v, typdown_getErrorString(code), code); + void *doc = typdown_parse(v, &code); + if (code != 0) { + printf("cannot parse '%s', error: %s (%d)\n", v, typdown_getErrorString(code), code); + typdown_free(doc); + return; + } + char *res = typdown_renderHTML(doc, &code); + if (code != 0) { + printf("cannot render '%s', error: %s (%d)\n", v, typdown_getErrorString(code), code); + typdown_free(doc); + return; + } + printf("%s\n", res); + free(res); + typdown_free(doc); } int main() { -- cgit v1.2.3