diff options
Diffstat (limited to 'examples/main.c')
| -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() { |
