mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 09:57:52 +01:00
Backport #30298 by wxiaoguang Fix #30292 To avoid unnecessary style overriding, use "div" instead of "code" Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
02bf0a8cd7
commit
45e8a884b8
@ -65,7 +65,7 @@ func createDefaultPolicy() *bluemonday.Policy {
|
|||||||
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^lines-num$`)).OnElements("td")
|
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^lines-num$`)).OnElements("td")
|
||||||
policy.AllowAttrs("data-line-number").OnElements("span")
|
policy.AllowAttrs("data-line-number").OnElements("span")
|
||||||
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^lines-code chroma$`)).OnElements("td")
|
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^lines-code chroma$`)).OnElements("td")
|
||||||
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^code-inner$`)).OnElements("code")
|
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^code-inner$`)).OnElements("div")
|
||||||
|
|
||||||
// For code preview (unicode escape)
|
// For code preview (unicode escape)
|
||||||
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^file-view( unicode-escaped)?$`)).OnElements("table")
|
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^file-view( unicode-escaped)?$`)).OnElements("table")
|
||||||
|
@ -36,10 +36,10 @@ func TestProcessorHelperCodePreview(t *testing.T) {
|
|||||||
<table class="file-view">
|
<table class="file-view">
|
||||||
<tbody><tr>
|
<tbody><tr>
|
||||||
<td class="lines-num"><span data-line-number="1"></span></td>
|
<td class="lines-num"><span data-line-number="1"></span></td>
|
||||||
<td class="lines-code chroma"><code class="code-inner"><span class="gh"># repo1</code></td>
|
<td class="lines-code chroma"><div class="code-inner"><span class="gh"># repo1</div></td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
<td class="lines-num"><span data-line-number="2"></span></td>
|
<td class="lines-num"><span data-line-number="2"></span></td>
|
||||||
<td class="lines-code chroma"><code class="code-inner"></span><span class="gh"></span></code></td>
|
<td class="lines-code chroma"><div class="code-inner"></span><span class="gh"></span></div></td>
|
||||||
</tr></tbody>
|
</tr></tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -63,7 +63,7 @@ func TestProcessorHelperCodePreview(t *testing.T) {
|
|||||||
<table class="file-view">
|
<table class="file-view">
|
||||||
<tbody><tr>
|
<tbody><tr>
|
||||||
<td class="lines-num"><span data-line-number="1"></span></td>
|
<td class="lines-num"><span data-line-number="1"></span></td>
|
||||||
<td class="lines-code chroma"><code class="code-inner"><span class="gh"># repo1</code></td>
|
<td class="lines-code chroma"><div class="code-inner"><span class="gh"># repo1</div></td>
|
||||||
</tr></tbody>
|
</tr></tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
{{- $lineEscapeStatus := index $.LineEscapeStatus $idx -}}
|
{{- $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>
|
<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}}
|
{{- end}}
|
||||||
<td class="lines-code chroma"><code class="code-inner">{{$line.FormattedContent}}</code></td>
|
<td class="lines-code chroma"><div class="code-inner">{{$line.FormattedContent}}</div></td>{{/* only div works, span generates incorrect HTML structure */}}
|
||||||
</tr>
|
</tr>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -432,7 +432,7 @@
|
|||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.markup code:not(.code-inner),
|
.markup code,
|
||||||
.markup tt {
|
.markup tt {
|
||||||
padding: 0.2em 0.4em;
|
padding: 0.2em 0.4em;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user