Skip to content

Commit 139979f

Browse files
author
Gusted
committed
Merge pull request '[v7.0/forgejo] [BUG] Center icon and callout text' (go-gitea#3027) from bp-v7.0/forgejo-6ffae46 into v7.0/forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3027 Reviewed-by: Earl Warren <[email protected]>
2 parents bc873f2 + 06e72e2 commit 139979f

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

modules/markup/markdown/callout/github.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func (g *GitHubCalloutTransformer) Transform(node *ast.Document, reader text.Rea
7272

7373
// create an emphasis to make it bold
7474
attentionParagraph := ast.NewParagraph()
75+
attentionParagraph.SetAttributeString("class", []byte("attention-title"))
7576
emphasis := ast.NewEmphasis(2)
7677
emphasis.SetAttributeString("class", []byte("attention-"+attentionType))
7778
firstParagraph.InsertBefore(firstParagraph, firstTextNode, emphasis)

modules/markup/markdown/callout/github_legacy.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,15 @@ func (g *GitHubLegacyCalloutTransformer) Transform(node *ast.Document, reader te
5151
// color the blockquote
5252
v.SetAttributeString("class", []byte("attention-header attention-"+calloutType))
5353

54-
// Prepend callout icon before the callout node itself
55-
firstParagraph.InsertBefore(firstParagraph, calloutNode, NewAttention(calloutType))
54+
// Create new parargaph.
55+
attentionParagraph := ast.NewParagraph()
56+
attentionParagraph.SetAttributeString("class", []byte("attention-title"))
57+
58+
// Move the callout node to the paragraph and insert the paragraph.
59+
attentionParagraph.AppendChild(attentionParagraph, NewAttention(calloutType))
60+
attentionParagraph.AppendChild(attentionParagraph, calloutNode)
61+
firstParagraph.Parent().InsertBefore(firstParagraph.Parent(), firstParagraph, attentionParagraph)
62+
firstParagraph.RemoveChild(firstParagraph, calloutNode)
5663
}
5764

5865
return ast.WalkContinue, nil

modules/markup/sanitizer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func createDefaultPolicy() *bluemonday.Policy {
6464
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^color-preview$`)).OnElements("span")
6565

6666
// For attention
67+
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^attention-title$`)).OnElements("p")
6768
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^attention-header attention-\w+$`)).OnElements("blockquote")
6869
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^attention-\w+$`)).OnElements("strong")
6970
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^attention-icon attention-\w+ svg octicon-[\w-]+$`)).OnElements("svg")

web_src/css/base.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,11 @@ input:-webkit-autofill:active,
11271127
margin: auto 0.5em auto 0;
11281128
}
11291129

1130+
.attention-title {
1131+
align-items: center;
1132+
display: flex;
1133+
}
1134+
11301135
blockquote.attention-note {
11311136
border-left-color: var(--color-blue-dark-1);
11321137
}

0 commit comments

Comments
 (0)