mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 12:54:53 -05: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:
parent
446a41d595
commit
f2fcd9dcd8
3 changed files with 7 additions and 3 deletions
|
@ -1435,7 +1435,7 @@ footer .ui.language .menu {
|
||||||
.repository.file.list #file-content .code-view .lines-code ol li,
|
.repository.file.list #file-content .code-view .lines-code ol li,
|
||||||
.repository.file.list #file-content .code-view .lines-num .hljs li,
|
.repository.file.list #file-content .code-view .lines-num .hljs li,
|
||||||
.repository.file.list #file-content .code-view .lines-code .hljs li {
|
.repository.file.list #file-content .code-view .lines-code .hljs li {
|
||||||
display: inline-block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.repository.file.list #file-content .code-view .lines-num pre li.active,
|
.repository.file.list #file-content .code-view .lines-num pre li.active,
|
||||||
|
|
|
@ -296,7 +296,7 @@
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
li {
|
li {
|
||||||
display: inline-block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
&.active {
|
&.active {
|
||||||
background: #ffffdd;
|
background: #ffffdd;
|
||||||
|
|
|
@ -212,7 +212,11 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
|
||||||
var output bytes.Buffer
|
var output bytes.Buffer
|
||||||
lines := strings.Split(fileContent, "\n")
|
lines := strings.Split(fileContent, "\n")
|
||||||
for index, line := range lines {
|
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())
|
ctx.Data["FileContent"] = gotemplate.HTML(output.String())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue