summaryrefslogtreecommitdiffstats
path: root/modules/indexer/code/search.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/indexer/code/search.go')
-rw-r--r--modules/indexer/code/search.go22
1 files changed, 6 insertions, 16 deletions
diff --git a/modules/indexer/code/search.go b/modules/indexer/code/search.go
index ca57b3ff88..29ed416541 100644
--- a/modules/indexer/code/search.go
+++ b/modules/indexer/code/search.go
@@ -6,8 +6,6 @@ package code
import (
"bytes"
- "html"
- gotemplate "html/template"
"strings"
"code.gitea.io/gitea/modules/highlight"
@@ -23,9 +21,8 @@ type Result struct {
UpdatedUnix timeutil.TimeStamp
Language string
Color string
- HighlightClass string
LineNumbers []int
- FormattedLines gotemplate.HTML
+ FormattedLines string
}
func indices(content string, selectionStartIndex, selectionEndIndex int) (int, int) {
@@ -80,19 +77,13 @@ func searchResult(result *SearchResult, startIndex, endIndex int) (*Result, erro
openActiveIndex := util.Max(result.StartIndex-index, 0)
closeActiveIndex := util.Min(result.EndIndex-index, len(line))
err = writeStrings(&formattedLinesBuffer,
- `<li>`,
- html.EscapeString(line[:openActiveIndex]),
- `<span class='active'>`,
- html.EscapeString(line[openActiveIndex:closeActiveIndex]),
- `</span>`,
- html.EscapeString(line[closeActiveIndex:]),
- `</li>`,
+ line[:openActiveIndex],
+ line[openActiveIndex:closeActiveIndex],
+ line[closeActiveIndex:],
)
} else {
err = writeStrings(&formattedLinesBuffer,
- `<li>`,
- html.EscapeString(line),
- `</li>`,
+ line,
)
}
if err != nil {
@@ -109,9 +100,8 @@ func searchResult(result *SearchResult, startIndex, endIndex int) (*Result, erro
UpdatedUnix: result.UpdatedUnix,
Language: result.Language,
Color: result.Color,
- HighlightClass: highlight.FileNameToHighlightClass(result.Filename),
LineNumbers: lineNumbers,
- FormattedLines: gotemplate.HTML(formattedLinesBuffer.String()),
+ FormattedLines: highlight.Code(result.Filename, formattedLinesBuffer.String()),
}, nil
}