X-Git-Url: https://git.armaanb.net/?a=blobdiff_plain;f=src%2Fstagit-index.c;h=2a23e8f943dd4de5df20c96ade90564193172515;hb=0bb810d3a94a225fbc7cf099bd92608de0baa45b;hp=8a4d97418d617179e388030d568650d09dcc3492;hpb=c0ab339d2a4e0eda5354ece2c826f4b786484097;p=stagit.git diff --git a/src/stagit-index.c b/src/stagit-index.c index 8a4d974..2a23e8f 100644 --- a/src/stagit-index.c +++ b/src/stagit-index.c @@ -8,6 +8,10 @@ #include +#ifdef HAS_CMARK +#include +#endif + #include "cp.h" static git_repository *repo; @@ -43,7 +47,7 @@ xmlencode(FILE *fp, const char *s, size_t len) case '\'': fputs("'" , fp); break; case '&': fputs("&", fp); break; case '"': fputs(""", fp); break; - default: fputc(*s, fp); + default: putc(*s, fp); } } } @@ -67,18 +71,43 @@ writeheader(char *path) { FILE *fp = fopen(path, "w"); fputs("\n" - "\n\n" + "\n\n" "\n" + "\n" "", fp); xmlencode(fp, description, strlen(description)); fprintf(fp, "\n\n", relpath); - fprintf(fp, "\n", relpath); + fprintf(fp, "\n", relpath); fputs("\n\n", fp); - fprintf(fp, "\n\n" - "\n" + "

", relpath); xmlencode(fp, description, strlen(description)); - fputs("

\n
\"\"

", relpath); + fprintf(fp, "

\n" - "
\n
\n
\n" + fputs("\n", fp); + + FILE *longdesc = fopen("desc.md", "r"); + if (longdesc == NULL) longdesc = fopen("desc", "r"); + if (longdesc != NULL) { + char c = fgetc(longdesc); +#ifdef HAS_CMARK + char buf[2048]; + while (c != EOF) { + strncat(buf, &c, 1); + c = fgetc(longdesc); + } + char *md = cmark_markdown_to_html(buf, strlen(buf), CMARK_OPT_DEFAULT); + fprintf(fp, md, relpath); + free(md); +#else + fputs("

\n", fp); + while (c != EOF) { + fprintf(fp, &c, relpath); + c = fgetc(longdesc); + } +#endif + fclose(longdesc); + } + + fputs("

\n
\n
\n" "\n" "" "" @@ -223,7 +252,7 @@ main(int argc, char *argv[]) /* copy css */ char cwd[PATH_MAX]; strcpy(cwd, getcwd(cwd, sizeof(cwd))); - cp("/usr/local/share/stagit/style.min.css", strcat(cwd, "/style.min.css")); + cp("/usr/local/share/stagit/style.css", strcat(cwd, "/style.css")); /* cleanup */ git_repository_free(repo);
NameDescriptionOwnerLast commit