Skip to content

Commit 245457d

Browse files
jaqralafriks
authored andcommitted
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 <[email protected]>
1 parent a45909b commit 245457d

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

public/css/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ footer .ui.left,footer .ui.right{line-height:40px}
216216
.inline-grouped-list>.ui{display:block;margin-top:5px;margin-bottom:10px}
217217
.inline-grouped-list>.ui:first-child{margin-top:1px}
218218
.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}
219-
.lines-num span{line-height:20px!important;padding:0 10px;cursor:pointer;display:block}
219+
.lines-num span:before{content:attr(data-line-number);line-height:20px!important;padding:0 10px;cursor:pointer;display:block}
220220
.lines-code,.lines-num{padding:0!important}
221221
.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}
222222
.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%}

public/less/_base.less

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,13 @@ footer {
920920
user-select: none;
921921

922922
span {
923-
line-height: 20px !important;
924-
padding: 0 10px;
925-
cursor: pointer;
926-
display: block;
923+
&:before {
924+
content: attr(data-line-number);
925+
line-height: 20px !important;
926+
padding: 0 10px;
927+
cursor: pointer;
928+
display: block;
929+
}
927930
}
928931
}
929932

routers/repo/view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
319319

320320
output.Reset()
321321
for i := 0; i < len(lines); i++ {
322-
output.WriteString(fmt.Sprintf(`<span id="L%d">%d</span>`, i+1, i+1))
322+
output.WriteString(fmt.Sprintf(`<span id="L%[1]d" data-line-number="%[1]d"></span>`, i+1))
323323
}
324324
ctx.Data["LineNums"] = gotemplate.HTML(output.String())
325325
}

0 commit comments

Comments
 (0)