Skip to content

Commit 87e04a7

Browse files
committed
fix styles
1 parent 540d07c commit 87e04a7

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

modules/markup/html_codepreview.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,13 @@ func codePreviewPatternProcessor(ctx *RenderContext, node *html.Node) {
7070
continue
7171
}
7272
next := node.NextSibling
73-
nodeText := node.Data
74-
node.Data = nodeText[:urlPosStart]
73+
textBefore := node.Data[:urlPosStart]
74+
textAfter := node.Data[urlPosEnd:]
75+
node.Data = textBefore
7576
node.Parent.InsertBefore(&html.Node{Type: html.RawNode, Data: string(h)}, next)
76-
node.Parent.InsertBefore(&html.Node{Type: html.TextNode, Data: nodeText[urlPosEnd:]}, next)
77+
if textAfter != "" {
78+
node.Parent.InsertBefore(&html.Node{Type: html.TextNode, Data: textAfter}, next)
79+
}
7780
node = next
7881
}
7982
}

modules/markup/sanitizer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ func createDefaultPolicy() *bluemonday.Policy {
6565
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^lines-num$`)).OnElements("td")
6666
policy.AllowAttrs("data-line-number").OnElements("span")
6767
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^lines-code chroma$`)).OnElements("td")
68+
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^code-inner$`)).OnElements("code")
6869

6970
// For code preview (unicode escape)
7071
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^file-view( unicode-escaped)?$`)).OnElements("table")

templates/base/markup_codepreview.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{{- $lineEscapeStatus := index $.LineEscapeStatus $idx -}}
1414
<td class="lines-escape">{{if $lineEscapeStatus.Escaped}}<a href="#" class="toggle-escape-button btn interact-bg" title="{{if $lineEscapeStatus.HasInvisible}}{{ctx.Locale.Tr "repo.invisible_runes_line"}} {{end}}{{if $lineEscapeStatus.HasAmbiguous}}{{ctx.Locale.Tr "repo.ambiguous_runes_line"}}{{end}}"></a>{{end}}</td>
1515
{{- end}}
16-
<td class="lines-code chroma">{{$line.FormattedContent}}</td>
16+
<td class="lines-code chroma"><code class="code-inner">{{$line.FormattedContent}}</code></td>
1717
</tr>
1818
{{- end -}}
1919
</tbody>

web_src/css/markup/content.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@
382382
text-align: center;
383383
}
384384

385-
.markup span.align-center span img
385+
.markup span.align-center span img,
386386
.markup span.align-center span video {
387387
margin: 0 auto;
388388
text-align: center;
@@ -432,7 +432,7 @@
432432
text-align: right;
433433
}
434434

435-
.markup code,
435+
.markup code:not(.code-inner),
436436
.markup tt {
437437
padding: 0.2em 0.4em;
438438
margin: 0;

0 commit comments

Comments
 (0)