diff --git a/stagit.c b/stagit.c
@@ -81,8 +81,17 @@ static char lastoidstr[GIT_OID_HEXSZ + 2]; /* id + newline + NUL byte */
static FILE *rcachefp, *wcachefp;
static const char *cachefile;
- void
-joinpath(char *buf, size_t bufsiz, const char *path, const char *path2)
+void write_markdown_readme(FILE *file, git_blob *readme)
+{
+ char *markdown = git_blob_rawcontent(readme);
+ char *html = cmark_markdown_to_html(markdown, strlen(markdown), 0);
+
+ fprintf(file, "%s", html);
+ free(html);
+ free(markdown);
+}
+
+void joinpath(char *buf, size_t bufsiz, const char *path, const char *path2)
{
int r;
@@ -1287,24 +1296,11 @@ main(int argc, char *argv[])
{
readme = "README.html";
fancy_readme = true;
-
- const char *tmp = "/tmp/stagit-tmp";
fp = efopen(readme, "w");
- // Copy the contents of the README to a temporary file
- FILE *tmpfile = efopen(tmp, "w");
- fprintf(tmpfile, "%s", git_blob_rawcontent((git_blob *)obj));
- fclose(tmpfile);
-
- // Write the header of the file
writeheader(fp, "README");
+ write_markdown_read(fp, (glit_blob*)obj);
fclose(fp);
-
- // Write the HTML using Pandoc
- system(
- "pandoc -f markdown -t html -o - /tmp/stagit-tmp >> README.html"
- );
- remove(tmp);
}
}
git_object_free(obj);