diff options
| author | Benjamin Linskey | 2026-04-23 10:58:37 -0400 |
|---|---|---|
| committer | Benjamin Linskey | 2026-04-23 10:58:37 -0400 |
| commit | df721c6ca9807202b70b0cee9688ec960b65090a (patch) | |
| tree | fd66a9cee4fdae5ce1f5db8740efcdfe021b88a4 | |
| download | cgit-md-filter-df721c6ca9807202b70b0cee9688ec960b65090a.tar.gz | |
Initial commit
| -rw-r--r-- | Makefile | 12 | ||||
| -rw-r--r-- | filter.c | 36 |
2 files changed, 48 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..da3c4d3 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +.PHONY: all +all: md-filter + +md-filter: filter.o + cc -Wall -Wextra -o md-filter filter.o `pkg-config --libs lowdown` -static + +filter.o: filter.c + cc -Wall -Wextra `pkg-config --cflags lowdown` -c -o filter.o filter.c + +.PHONY: clean +clean: + rm filter.o md-filter diff --git a/filter.c b/filter.c new file mode 100644 index 0000000..75e8c2e --- /dev/null +++ b/filter.c @@ -0,0 +1,36 @@ +#include <err.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/queue.h> + +#include <lowdown.h> + +int main(void) { + struct lowdown_opts opts; + char *buf; + size_t bufsz; + + memset(&opts, 0, sizeof(struct lowdown_opts)); + opts.type = LOWDOWN_HTML; + opts.feat = LOWDOWN_FOOTNOTES | + LOWDOWN_AUTOLINK | + LOWDOWN_TABLES | + LOWDOWN_SUPER | + LOWDOWN_STRIKE | + LOWDOWN_FENCED | + LOWDOWN_COMMONMARK | + LOWDOWN_DEFLIST | + LOWDOWN_IMG_EXT | + LOWDOWN_METADATA; + opts.oflags = LOWDOWN_HTML_HEAD_IDS | + LOWDOWN_HTML_NUM_ENT | + LOWDOWN_HTML_OWASP | + LOWDOWN_SMARTY; + if (!lowdown_file(&opts, stdin, &buf, &bufsz, NULL)) + errx(1, "lowdown_file"); + fwrite(buf, 1, bufsz, stdout); + free(buf); + + return 0; +} |