]> git.armaanb.net Git - stagit.git/blobdiff - src/stagit.c
Make alt text cleaner
[stagit.git] / src / stagit.c
index b5580b8cc772f7bebd6533cd437d0aae98ef6766..c39e9ba54b0b6881a275fd5e9cd44308d4e76038 100644 (file)
 #include <unistd.h>
 
 #include <git2.h>
+
+#ifdef HAS_CMARK
 #include <cmark-gfm.h>
+#endif
 
 #include "cp.h"
 #include "compat.h"
@@ -347,7 +350,7 @@ void
 writeheader(FILE *fp, const char *title)
 {
        fputs("<!DOCTYPE html>\n"
-               "<html>\n<head>\n"
+               "<html lang=\"en\">\n<head>\n"
                "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"
                "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n"
                "<title>", fp);
@@ -364,7 +367,7 @@ writeheader(FILE *fp, const char *title)
        fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"%sstyle.css\" />\n", relpath);
        fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"%ssyntax.css\" />\n", relpath);
        fputs("</head>\n<body>\n<table><tr><td>", fp);
-       fprintf(fp, "<a href=\"../%s\"><img src=\"%slogo.png\" alt=\"\" width=\"32\" height=\"32\" /></a>",
+       fprintf(fp, "<a href=\"../%s\"><img alt=\"Home\" src=\"%slogo.png\" alt=\"\" width=\"32\" height=\"32\" /></a>",
                relpath, relpath);
        fputs("</td><td><h1>", fp);
        xmlencode(fp, strippedname, strlen(strippedname));
@@ -414,12 +417,17 @@ void
 call_chroma(const char *filename, FILE *fp, const char *s, size_t len)
 {
        htmlized = false;
+       char *html = "";
        // Flush HTML-file
        fflush(fp);
 
-       char *html = cmark_markdown_to_html(s, len, CMARK_OPT_DEFAULT);
+#ifdef HAS_CMARK
+       html = cmark_markdown_to_html(s, len, CMARK_OPT_DEFAULT);
        if (strcmp(get_ext(filename), "md") == 0) htmlized = true;
+#endif
 
+
+#ifdef HAS_CHROMA
        if (!htmlized) {
                // Copy STDOUT
                int stdout_copy = dup(1);
@@ -450,6 +458,9 @@ call_chroma(const char *filename, FILE *fp, const char *s, size_t len)
        } else {
                fprintf(fp, "%s", html);
        }
+#else
+               fprintf(fp, "<pre>%s</pre>", s);
+#endif
 }
 
 void