Skip to content

Commit

Permalink
fix styles
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Apr 2, 2024
1 parent 540d07c commit 87e04a7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions modules/markup/html_codepreview.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ func codePreviewPatternProcessor(ctx *RenderContext, node *html.Node) {
continue
}
next := node.NextSibling
nodeText := node.Data
node.Data = nodeText[:urlPosStart]
textBefore := node.Data[:urlPosStart]
textAfter := node.Data[urlPosEnd:]
node.Data = textBefore
node.Parent.InsertBefore(&html.Node{Type: html.RawNode, Data: string(h)}, next)
node.Parent.InsertBefore(&html.Node{Type: html.TextNode, Data: nodeText[urlPosEnd:]}, next)
if textAfter != "" {
node.Parent.InsertBefore(&html.Node{Type: html.TextNode, Data: textAfter}, next)
}
node = next
}
}
1 change: 1 addition & 0 deletions modules/markup/sanitizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func createDefaultPolicy() *bluemonday.Policy {
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^lines-num$`)).OnElements("td")
policy.AllowAttrs("data-line-number").OnElements("span")
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^lines-code chroma$`)).OnElements("td")
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^code-inner$`)).OnElements("code")

// For code preview (unicode escape)
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^file-view( unicode-escaped)?$`)).OnElements("table")
Expand Down
2 changes: 1 addition & 1 deletion templates/base/markup_codepreview.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{- $lineEscapeStatus := index $.LineEscapeStatus $idx -}}
<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>
{{- end}}
<td class="lines-code chroma">{{$line.FormattedContent}}</td>
<td class="lines-code chroma"><code class="code-inner">{{$line.FormattedContent}}</code></td>
</tr>
{{- end -}}
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions web_src/css/markup/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@
text-align: center;
}

.markup span.align-center span img
.markup span.align-center span img,
.markup span.align-center span video {
margin: 0 auto;
text-align: center;
Expand Down Expand Up @@ -432,7 +432,7 @@
text-align: right;
}

.markup code,
.markup code:not(.code-inner),
.markup tt {
padding: 0.2em 0.4em;
margin: 0;
Expand Down

0 comments on commit 87e04a7

Please sign in to comment.