#include #include #include #include #define MAX_SIZE 1024 #define BUFFER_SIZE 4096 /* TODO: Add custom syntax filter */ int apply_custom_syntax(char *input); int main() { size_t cap = BUFFER_SIZE; size_t len = 0; char *markdown_input = malloc(cap); char buffer[BUFFER_SIZE]; while (fgets(buffer, sizeof(buffer), stdin) != NULL) { size_t line_len = strlen(buffer); if (len + line_len >= cap) { cap *= 2; markdown_input = realloc(markdown_input, cap); } strcpy(markdown_input + len, buffer); len += line_len; } char *html_output = cmark_markdown_to_html(markdown_input, len, CMARK_OPT_DEFAULT); if (html_output) { printf("%s", html_output); free(html_output); } free(markdown_input); return 0; }