mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Support CRLF when splitting code lines for display (#1862)
* Support CRLF when splitting code lines for display * refactor, fix mixed match * fmt * split on both LF and CRLF, use raw literals in regexes * simplify
This commit is contained in:
@@ -212,7 +212,11 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
|
||||
var output bytes.Buffer
|
||||
lines := strings.Split(fileContent, "\n")
|
||||
for index, line := range lines {
|
||||
output.WriteString(fmt.Sprintf(`<li class="L%d" rel="L%d">%s</li>`, index+1, index+1, gotemplate.HTMLEscapeString(line)) + "\n")
|
||||
line = gotemplate.HTMLEscapeString(line)
|
||||
if index != len(lines)-1 {
|
||||
line += "\n"
|
||||
}
|
||||
output.WriteString(fmt.Sprintf(`<li class="L%d" rel="L%d">%s</li>`, index+1, index+1, line))
|
||||
}
|
||||
ctx.Data["FileContent"] = gotemplate.HTML(output.String())
|
||||
|
||||
|
Reference in New Issue
Block a user