commit 4902c8e7ef17c1dbde525fb94bde36977a11e6aa
parent f6e41f494d9882252759e3bdf14a6d183ee37172
Author: alex wennerberg <alex@alexwennerberg.com>
Date: Sat, 23 Apr 2022 22:43:57 -0700
Add libcommonmark
I am not good at C
Diffstat:
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
@@ -11,9 +11,11 @@ DOCPREFIX = ${PREFIX}/share/doc/${NAME}
LIBGIT_INC = -I/usr/local/include
LIBGIT_LIB = -L/usr/local/lib -lgit2
+CMARK_LIB = -L/usr/local/lib -lcmark
+
# use system flags.
STAGIT_CFLAGS = ${LIBGIT_INC} ${CFLAGS}
-STAGIT_LDFLAGS = ${LIBGIT_LIB} ${LDFLAGS}
+STAGIT_LDFLAGS = ${LIBGIT_LIB} ${CMARK_LIB} ${LDFLAGS}
STAGIT_CPPFLAGS = -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_BSD_SOURCE
SRC = \
diff --git a/stagit.c b/stagit.c
@@ -13,6 +13,7 @@
#include <unistd.h>
#include <git2.h>
+#include <cmark.h>
#include "compat.h"
@@ -1000,7 +1001,12 @@ writeblob(git_object *obj, const char *fpath, const char *rpath, const char *fil
if (git_blob_is_binary((git_blob *)obj))
fputs("<p>Binary file.</p>\n", fp);
- else
+ else if (!strcmp(filename,"README.md")) {
+ const char *s = git_blob_rawcontent((git_blob *)obj);
+ const char *html = cmark_markdown_to_html(s, strlen(s), 0);
+ fputs(html, fp);
+ }
+ else
lc = writeblobhtml(fp, (git_blob *)obj);
writefooter(fp);