mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 12:54:53 -05:00
Move line number to :before attr to hide from search on browser (#8002)
* Move line number to :before attr to hide from search on browser * Use same variable in WriteString Co-Authored-By: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
a45909be90
commit
245457d4d3
3 changed files with 9 additions and 6 deletions
|
@ -216,7 +216,7 @@ footer .ui.left,footer .ui.right{line-height:40px}
|
||||||
.inline-grouped-list>.ui{display:block;margin-top:5px;margin-bottom:10px}
|
.inline-grouped-list>.ui{display:block;margin-top:5px;margin-bottom:10px}
|
||||||
.inline-grouped-list>.ui:first-child{margin-top:1px}
|
.inline-grouped-list>.ui:first-child{margin-top:1px}
|
||||||
.lines-num{vertical-align:top;text-align:right!important;color:#999;background:#f5f5f5;width:1%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
|
.lines-num{vertical-align:top;text-align:right!important;color:#999;background:#f5f5f5;width:1%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
|
||||||
.lines-num span{line-height:20px!important;padding:0 10px;cursor:pointer;display:block}
|
.lines-num span:before{content:attr(data-line-number);line-height:20px!important;padding:0 10px;cursor:pointer;display:block}
|
||||||
.lines-code,.lines-num{padding:0!important}
|
.lines-code,.lines-num{padding:0!important}
|
||||||
.lines-code .hljs,.lines-code ol,.lines-code pre,.lines-num .hljs,.lines-num ol,.lines-num pre{background-color:#fff;margin:0;padding:0!important}
|
.lines-code .hljs,.lines-code ol,.lines-code pre,.lines-num .hljs,.lines-num ol,.lines-num pre{background-color:#fff;margin:0;padding:0!important}
|
||||||
.lines-code .hljs li,.lines-code ol li,.lines-code pre li,.lines-num .hljs li,.lines-num ol li,.lines-num pre li{display:block;width:100%}
|
.lines-code .hljs li,.lines-code ol li,.lines-code pre li,.lines-num .hljs li,.lines-num ol li,.lines-num pre li{display:block;width:100%}
|
||||||
|
|
|
@ -920,12 +920,15 @@ footer {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
|
||||||
span {
|
span {
|
||||||
|
&:before {
|
||||||
|
content: attr(data-line-number);
|
||||||
line-height: 20px !important;
|
line-height: 20px !important;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.lines-num,
|
.lines-num,
|
||||||
.lines-code {
|
.lines-code {
|
||||||
|
|
|
@ -319,7 +319,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
|
||||||
|
|
||||||
output.Reset()
|
output.Reset()
|
||||||
for i := 0; i < len(lines); i++ {
|
for i := 0; i < len(lines); i++ {
|
||||||
output.WriteString(fmt.Sprintf(`<span id="L%d">%d</span>`, i+1, i+1))
|
output.WriteString(fmt.Sprintf(`<span id="L%[1]d" data-line-number="%[1]d"></span>`, i+1))
|
||||||
}
|
}
|
||||||
ctx.Data["LineNums"] = gotemplate.HTML(output.String())
|
ctx.Data["LineNums"] = gotemplate.HTML(output.String())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue