History

Server-side syntax highlighting for all code (#12047)

* Server-side syntax hilighting for all code This PR does a few things: * Remove all traces of highlight.js * Use chroma library to provide fast syntax hilighting directly on the server * Provide syntax hilighting for diffs * Re-style both unified and split diffs views * Add custom syntax hilighting styling for both regular and arc-green Fixes #7729 Fixes #10157 Fixes #11825 Fixes #7728 Fixes #3872 Fixes #3682 And perhaps gets closer to #9553 * fix line marker * fix repo search * Fix single line select * properly load settings * npm uninstall highlight.js * review suggestion * code review * forgot to call function * fix test * Apply suggestions from code review suggestions from @silverwind thanks Co-authored-by: silverwind <me@silverwind.io> * code review * copy/paste error * Use const for highlight size limit * Update web_src/less/_repository.less Co-authored-by: Lauris BH <lauris@nix.lv> * update size limit to 1MB and other styling tweaks * fix highlighting for certain diff sections * fix test * add worker back as suggested

mrsdizzie committed 6 years ago

Commit af7ffaa1 parent ce5f2b9336 files · +37289 −765Browse files

Showing the changes to services/gitdiff/gitdiff_test.go (1 of 336 files). Show all

Unified · Split

services/gitdiff/gitdiff_test.go+5−2
@@ -15,6 +15,8 @@ import ( · 14 unmodified lines
15 "code.gitea.io/gitea/modules/git"15 "code.gitea.io/gitea/modules/git"
16 "code.gitea.io/gitea/modules/setting"16 "code.gitea.io/gitea/modules/setting"
17 17
18 "gopkg.in/ini.v1"
19
18 dmp "github.com/sergi/go-diff/diffmatchpatch"20 dmp "github.com/sergi/go-diff/diffmatchpatch"
19 "github.com/stretchr/testify/assert"21 "github.com/stretchr/testify/assert"
20)22)
@@ -26,14 +28,15 @@ func assertEqual(t *testing.T, s1 string, s2 template.HTML) { · 5 unmodified lines
26}28}
27 29
28func TestDiffToHTML(t *testing.T) {30func TestDiffToHTML(t *testing.T) {
29 assertEqual(t, "foo <span class=\"added-code\">bar</span> biz", diffToHTML([]dmp.Diff{31 setting.Cfg = ini.Empty()
32 assertEqual(t, "foo <span class=\"added-code\">bar</span> biz", diffToHTML("", []dmp.Diff{
30 {Type: dmp.DiffEqual, Text: "foo "},33 {Type: dmp.DiffEqual, Text: "foo "},
31 {Type: dmp.DiffInsert, Text: "bar"},34 {Type: dmp.DiffInsert, Text: "bar"},
32 {Type: dmp.DiffDelete, Text: " baz"},35 {Type: dmp.DiffDelete, Text: " baz"},
33 {Type: dmp.DiffEqual, Text: " biz"},36 {Type: dmp.DiffEqual, Text: " biz"},
34 }, DiffLineAdd))37 }, DiffLineAdd))
35 38
36 assertEqual(t, "foo <span class=\"removed-code\">bar</span> biz", diffToHTML([]dmp.Diff{39 assertEqual(t, "foo <span class=\"removed-code\">bar</span> biz", diffToHTML("", []dmp.Diff{
37 {Type: dmp.DiffEqual, Text: "foo "},40 {Type: dmp.DiffEqual, Text: "foo "},
38 {Type: dmp.DiffDelete, Text: "bar"},41 {Type: dmp.DiffDelete, Text: "bar"},
39 {Type: dmp.DiffInsert, Text: " baz"},42 {Type: dmp.DiffInsert, Text: " baz"},