site

A custom static site generator written in C.
git clone https://unitehenry.com/git/site.git
Log | Files | Refs | README

commit cfc7e88a54d6da607ab6d1d0f6eeff5122101a3d
parent 8014d719cb540c58d515abfe2d2534f264ba8717
Author: Henry Unite <unitehenry@gmail.com>
Date:   Thu,  9 Apr 2026 03:19:47 +0000

feat: run pandoc

Diffstat:
Msrc/main.c | 24+++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/main.c b/src/main.c @@ -45,19 +45,33 @@ void get_content_files(StringList *list, char *content_path) { closedir(dr); } +FILE* run_pandoc(char* content_path) { + char *PANDOC_CMD = "pandoc "; + + size_t command_len = strlen(content_path) + strlen(PANDOC_CMD) + 2; + + char command[command_len]; + + snprintf(command, sizeof(command), "%s %s", PANDOC_CMD, content_path); + + return popen(command, "w"); +} + void generate_pages(StringList *list) { int i = 0; while (list->strings[i] != NULL) { - size_t command_len = strlen(list->strings[i]) + strlen("pandoc ") + 2; + FILE *fp = run_pandoc(list->strings[i]); - char command[command_len]; + char *line = NULL; - snprintf(command, sizeof(command), "pandoc %s", list->strings[i]); + size_t len = 0; - printf("%s\n", command); + ssize_t read; - FILE *fp = popen(command, "w"); + while ((read = getline(&line, &len, fp)) != -1) { + printf("%s", line); + } fclose(fp);