static long long nlogcommits = -1; /* < 0 indicates not used */
bool htmlized; /* true if markdoown converted to HTML */
+static char oldfilename[PATH_MAX]; /* filename of the last file */
/* cache */
static git_oid lastoid;
if (strcmp(get_ext(filename), "md") == 0) htmlized = true;
#endif
-
#ifdef HAS_CHROMA
if (!htmlized) {
// Copy STDOUT
fputs("<p> ", fp);
xmlencode(fp, filename, strlen(filename));
fprintf(fp, " (%s)", convertbytes((int)filesize));
- fputs("</p><hr/>", fp);
+
+#ifdef HAS_CMARK
+ char newfpath[PATH_MAX];
+ char newfilename[PATH_MAX];
+ if (strcmp(get_ext(filename), "md") == 0) {
+ fprintf(fp, " <a href=\"%s.html-raw\">View raw</a>", filename);
+ strcpy(newfpath, fpath);
+ strcat(newfpath, "-raw");
+
+ strcpy(newfilename, filename);
+ strcat(newfilename, "-raw");
+ strcpy(oldfilename, filename);
+
+ /* NOTE: recurses */
+ writeblob(obj, newfpath, newfilename, filesize);
+ } else if (strcmp(get_ext(filename), "md-raw" ) == 0) {
+ fprintf(fp, " <a href=\"%s.html\">View rendered</a>", oldfilename);
+ }
+#endif
+
+ fputs(".</p><hr/>", fp);
if (git_blob_is_binary((git_blob *)obj)) {
fputs("<p>Binary file.</p>\n", fp);
writeblobhtml(filename, fp, (git_blob *)obj);
if (ferror(fp))
err(1, "fwrite");
- else if (htmlized) {
- /* NOTE: recurses */
- char newfpath[PATH_MAX];
- strcat(newfpath, fpath);
- char newfilename[PATH_MAX];
- strcat(newfilename, filename);
- writeblob(obj, strcat(newfpath, "-raw"),
- strcat(newfilename, "-raw"), filesize);
- // TODO: Add view-raw button
- }
}
writefooter(fp);