diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-05-01 18:33:16 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-05-01 18:33:21 +0200 |
| commit | 3e00c224007db19cdc7869435967c5decea570a5 (patch) | |
| tree | 2e08f1a91e5930c1cc6509707581c83b8508c128 /examples | |
| parent | a9e8d0e9c929bec830b086e473ef1362e1f873d9 (diff) | |
feat(lib): introduce document notion in C ABI
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/main.c | 22 |
1 files changed, 16 insertions, 6 deletions
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 <stdlib.h> #include <stdio.h> #include <stdint.h> -#include "typdown.h" +#include <typdown.h> 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() { |
