diff options
context:
space:
mode:
Diffstat (limited to 'source/ui-tree.c')
-rw-r--r--source/ui-tree.c9
1 file changed, 8 insertions, 1 deletion
diff --git a/source/ui-tree.c b/source/ui-tree.c
index cbaca38..9181b1b 100644
--- a/source/ui-tree.c
+++ b/source/ui-tree.c
@@ -30,6 +30,7 @@ struct walk_tree_context {
static void print_text_buffer(const char *name, char *buf, unsigned long size)
{
unsigned long lineno, idx;
+ const char *ext;
const char *numberfmt = "<a id='n%1$d' href='#n%1$d'>%1$d</a>\n";
html("<table summary='blob content' class='blob'>\n");
@@ -64,7 +65,13 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size)
return;
}
- html("<td class='lines'><pre><code>");
+ /* No source filter is configured, so tag the code with its file
+ * extension (or bare name, for Makefile and the like) and let
+ * cgit.js highlight it client-side. */
+ ext = strrchr(name, '.');
+ html("<td class='lines'><pre><code data-lang='");
+ html_attr(ext && ext[1] ? ext + 1 : name);
+ html("'>");
html_txt(buf);
html("</code></pre></td></tr></table>\n");
}