cerrado @ 154f68bfd9ab4660dc764dbed6190289082b5c94

feat: Add syntax highlight to diff
 1diff --git a/pkg/handler/git/handler.go b/pkg/handler/git/handler.go
 2index 9c7ba5b1ee25615a2347ae54a661ea06372a33c6..80f7de6f1b36030c4d8f4325d523da0e0555e9fd 100644
 3--- a/pkg/handler/git/handler.go
 4+++ b/pkg/handler/git/handler.go
 5@@ -361,12 +361,31 @@ 	if err != nil {
 6 		return err
 7 	}
 8 
 9+	lexer := lexers.Get("diff")
10+	style := styles.Get(g.config.GetSyntaxHighlight())
11+
12+	formatter := html.New(
13+		html.WithLineNumbers(true),
14+		html.WithLinkableLineNumbers(true, "L"),
15+	)
16+
17+	iterator, err := lexer.Tokenise(nil, diff)
18+	if err != nil {
19+		return err
20+	}
21+
22+	var code bytes.Buffer
23+	err = formatter.Format(&code, style, iterator)
24+	if err != nil {
25+		return err
26+	}
27+
28 	gitList := &templates.GitItemPage{
29 		Name: name,
30 		Ref:  ref,
31 		GitItemBase: &templates.GitItemCommitPage{
32 			Commit: commit,
33-			Diff:   diff,
34+			Diff:   code.Bytes(),
35 		},
36 	}
37 	templates.WritePageTemplate(w, gitList, r.Context())
38diff --git a/templates/gititemcommit.qtpl b/templates/gititemcommit.qtpl
39index d223315dd0c8ffafe05139e1e21fd3f121dc78c9..ec67757ca324adb576499f3c9f63b29ad647f110 100644
40--- a/templates/gititemcommit.qtpl
41+++ b/templates/gititemcommit.qtpl
42@@ -3,7 +3,7 @@
43 {% code
44 type GitItemCommitPage struct {
45     Commit *object.Commit
46-    Diff string
47+    Diff []byte
48 }
49 %}
50 
51@@ -14,6 +14,6 @@ <div class="event-list">
52   {%= Commit(name, g.Commit, true) %}
53 </div>
54 <div class="code-view">
55-<pre>{%s g.Diff %}</pre>
56+<pre>{%z= g.Diff %}</pre>
57 </div>
58 {% endfunc %}
59diff --git a/templates/gititemcommit.qtpl.go b/templates/gititemcommit.qtpl.go
60index 8048e5878e26da40142490268067ed5d5eb18b70..7e458f31feba2b674f8d16d2f06e84f4beecfa3d 100644
61--- a/templates/gititemcommit.qtpl.go
62+++ b/templates/gititemcommit.qtpl.go
63@@ -23,7 +23,7 @@
64 //line templates/gititemcommit.qtpl:4
65 type GitItemCommitPage struct {
66 	Commit *object.Commit
67-	Diff   string
68+	Diff   []byte
69 }
70 
71 //line templates/gititemcommit.qtpl:10
72@@ -73,7 +73,7 @@ </div>
73 <div class="code-view">
74 <pre>`)
75 //line templates/gititemcommit.qtpl:17
76-	qw422016.E().S(g.Diff)
77+	qw422016.N().Z(g.Diff)
78 //line templates/gititemcommit.qtpl:17
79 	qw422016.N().S(`</pre>
80 </div>