Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve code diff highlight, fix incorrect rendered diff result #19958

Merged
merged 34 commits into from Jul 23, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7850972
Improve code highlight
wxiaoguang Jun 13, 2022
ca6a537
Merge branch 'main' into fix-code-highlight
wxiaoguang Jun 13, 2022
f0e2f97
remove unnecessary code, add more comments
wxiaoguang Jun 13, 2022
ec8da9e
Merge branch 'main' into fix-code-highlight
wxiaoguang Jun 13, 2022
de042fc
Merge branch 'main' into fix-code-highlight
wxiaoguang Jun 14, 2022
62eb155
clear edge cases, fine tune tests
wxiaoguang Jun 14, 2022
bb64dff
remove line wrapper tags when doing highlight code diff
wxiaoguang Jun 15, 2022
9b183f5
Merge branch 'main' into fix-code-highlight
wxiaoguang Jun 15, 2022
f172f88
Merge branch 'main' into fix-code-highlight
wxiaoguang Jun 15, 2022
6226d38
Merge branch 'main' into fix-code-highlight
wxiaoguang Jun 17, 2022
adaf320
fine tune
wxiaoguang Jun 17, 2022
9b5b079
Merge branch 'main' into fix-code-highlight
wxiaoguang Jun 17, 2022
4aa94e8
Update services/gitdiff/gitdiff.go
wxiaoguang Jun 17, 2022
17e0660
Merge branch 'main' into fix-code-highlight
lunny Jun 18, 2022
77445c2
fine tune comments
wxiaoguang Jun 18, 2022
6b359d9
Merge branch 'main' into fix-code-highlight
wxiaoguang Jun 18, 2022
9953e09
Merge branch 'main' into fix-code-highlight
wxiaoguang Jun 18, 2022
5fc6801
Merge branch 'main' into fix-code-highlight
lunny Jun 18, 2022
57f7bf8
Merge branch 'main' into fix-code-highlight
lunny Jun 27, 2022
47030f1
Merge branch 'main' into fix-code-highlight
lafriks Jun 27, 2022
27c78e1
Merge branch 'main' into fix-code-highlight
zeripath Jul 6, 2022
df5fef8
Update gitdiff.go
wxiaoguang Jul 7, 2022
843579a
Update gitdiff.go
wxiaoguang Jul 7, 2022
2e798d8
Update gitdiff.go
wxiaoguang Jul 7, 2022
ece0e3f
more tests
wxiaoguang Jul 9, 2022
c9a1566
private function & private struct
wxiaoguang Jul 9, 2022
f21f422
demo for why the tags are all closed
wxiaoguang Jul 9, 2022
3c2aa66
add comment
wxiaoguang Jul 9, 2022
90c6440
placeholder for html entity
wxiaoguang Jul 9, 2022
dc74baf
fine tune comments
wxiaoguang Jul 9, 2022
4afb1cc
always output the code/name part of the html entities if the placehol…
wxiaoguang Jul 9, 2022
4d1d8a4
fine tune comments
wxiaoguang Jul 9, 2022
9cf358b
demo why the tags are always balanced
wxiaoguang Jul 9, 2022
e6215ae
Merge branch 'main' into fix-code-highlight
wxiaoguang Jul 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions modules/highlight/highlight.go
Expand Up @@ -40,9 +40,11 @@ var (
// NewContext loads custom highlight map from local config
func NewContext() {
once.Do(func() {
keys := setting.Cfg.Section("highlight.mapping").Keys()
for i := range keys {
highlightMapping[keys[i].Name()] = keys[i].Value()
if setting.Cfg != nil {
keys := setting.Cfg.Section("highlight.mapping").Keys()
for i := range keys {
highlightMapping[keys[i].Name()] = keys[i].Value()
}
}

// The size 512 is simply a conservative rule of thumb
Expand Down