Improve code diff highlight, fix incorrect rendered diff result (#19958)
Use Unicode placeholders to replace HTML tags and HTML entities first, then do diff, then recover the HTML tags and HTML entities. Now the code diff with highlight has stable behavior, and won't emit broken tags.
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user