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
1515 "code.gitea.io/gitea/modules/git"
1616 "code.gitea.io/gitea/modules/setting"
1717
18+ "gopkg.in/ini.v1"
19+
1820 dmp "github.com/sergi/go-diff/diffmatchpatch"
1921 "github.com/stretchr/testify/assert"
2022 )
@@ -26,14 +28,15 @@ func assertEqual(t *testing.T, s1 string, s2 template.HTML) { · 5 unmodified lines
2628 }
2729
2830 func 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{
3033 {Type: dmp.DiffEqual, Text: "foo "},
3134 {Type: dmp.DiffInsert, Text: "bar"},
3235 {Type: dmp.DiffDelete, Text: " baz"},
3336 {Type: dmp.DiffEqual, Text: " biz"},
3437 }, DiffLineAdd))
3538
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{
3740 {Type: dmp.DiffEqual, Text: "foo "},
3841 {Type: dmp.DiffDelete, Text: "bar"},
3942 {Type: dmp.DiffInsert, Text: " baz"},