- commit
- 2001bd104b6cd3a130d7a56184b9bb87b82afbc7
- parent
- 21f30b3ace4f14a5d91d752377a2858474f6ce10
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-03-28 08:32
render readme using cmark
Diffstat
M | Makefile | 7 | +++++-- |
M | stagit.c | 12 | ++++++++++++ |
2 files changed, 17 insertions, 2 deletions
diff --git a/Makefile b/Makefile
@@ -11,10 +11,13 @@ DOCPREFIX = ${PREFIX}/share/doc/${NAME} 11 11 LIBGIT_INC = -I/usr/local/include 12 12 LIBGIT_LIB = -L/usr/local/lib -lgit2 13 13 -1 14 CMARKLIBS = -lcmark -1 15 CMARKFLAGS = -DCMARK -1 16 14 17 # use system flags. 15 18 STAGIT_CFLAGS = ${LIBGIT_INC} ${CFLAGS}16 -1 STAGIT_LDFLAGS = ${LIBGIT_LIB} ${LDFLAGS}17 -1 STAGIT_CPPFLAGS = -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_BSD_SOURCE-1 19 STAGIT_LDFLAGS = ${LIBGIT_LIB} ${CMARKLIBS} ${LDFLAGS} -1 20 STAGIT_CPPFLAGS = -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_BSD_SOURCE ${CMARKFLAGS} 18 21 19 22 SRC = \ 20 23 stagit.c\
diff --git a/stagit.c b/stagit.c
@@ -14,6 +14,10 @@ 14 14 15 15 #include <git2.h> 16 16 -1 17 #ifdef CMARK -1 18 #include <cmark.h> -1 19 #endif -1 20 17 21 #include "compat.h" 18 22 19 23 struct deltainfo { @@ -426,9 +430,17 @@ writereadmehtml(FILE *fp, const git_blob *blob) 426 430 const void *raw = git_blob_rawcontent(blob); 427 431 git_off_t len = git_blob_rawsize(blob); 428 432 -1 433 #ifdef CMARK -1 434 char *rendered = cmark_markdown_to_html(raw, len, CMARK_OPT_SAFE); -1 435 fputs("<div id=\"readme\">\n", fp); -1 436 fputs(rendered, fp); -1 437 fputs("</div>\n", fp); -1 438 free(rendered); -1 439 #else 429 440 fputs("<pre id=\"readme\">\n", fp); 430 441 fwrite(raw, 1, len, fp); 431 442 fputs("</pre>\n", fp); -1 443 #endif 432 444 } 433 445 434 446 void