]> git.armaanb.net Git - stagit.git/blobdiff - src/stagit.c
Switch to Chroma for syntax highlighting
[stagit.git] / src / stagit.c
index aa99c7767eff014f68b0ec0477f6e1ac94b83a4c..6ffcea52cdbe0b730d7b363e4da01b2e740cf053 100644 (file)
@@ -397,7 +397,7 @@ writefooter(FILE *fp)
 }
 
 int
-call_py(const char *filename, FILE *fp, const char *s, size_t len)
+call_chroma(const char *filename, FILE *fp, const char *s, size_t len)
 {
        // Flush HTML-file
        fflush(fp);
@@ -406,8 +406,10 @@ call_py(const char *filename, FILE *fp, const char *s, size_t len)
        // Redirect STDOUT
        dup2(fileno(fp), 1);
 
-       // Python Pygments script for syntax highlighting.
-       FILE *child = popen("/usr/local/share/stagit/highlight.py", "w");
+       char cmd[] = "chroma --html --html-only --html-lines --html-lines-table --filename ";
+       strcat(cmd, filename);
+
+       FILE *child = popen(cmd, "w");
        if (child == NULL) {
                printf("child is null: %s", strerror(errno));
                exit(1);
@@ -429,7 +431,7 @@ call_py(const char *filename, FILE *fp, const char *s, size_t len)
        return lc;
 }
 
-int
+       int
 writeblobhtml(const char *filename, FILE *fp, const git_blob *blob)
 {
        int lc = 0;
@@ -437,21 +439,21 @@ writeblobhtml(const char *filename, FILE *fp, const git_blob *blob)
        git_off_t len = git_blob_rawsize(blob);
 
        if (len > 0) {
-               lc = call_py(filename, fp, s, len);
+               lc = call_chroma(filename, fp, s, len);
        }
 
        return lc;
 }
 
-void
+       void
 printcommit(FILE *fp, struct commitinfo *ci)
 {
        fprintf(fp, "<b>commit</b> <a href=\"%scommit/%s.html\">%s</a>\n",
-               relpath, ci->oid, ci->oid);
+                       relpath, ci->oid, ci->oid);
 
        if (ci->parentoid[0])
                fprintf(fp, "<b>parent</b> <a href=\"%scommit/%s.html\">%s</a>\n",
-                       relpath, ci->parentoid, ci->parentoid);
+                               relpath, ci->parentoid, ci->parentoid);
 
        if (ci->author) {
                fputs("<b>Author:</b> ", fp);
@@ -471,7 +473,7 @@ printcommit(FILE *fp, struct commitinfo *ci)
        }
 }
 
-void
+       void
 printshowfile(FILE *fp, struct commitinfo *ci)
 {
        const git_diff_delta *delta;