mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-21 12:44:49 -05:00
Merge pull request '[v9.0/forgejo] fix: remove softbreak from github legacy callout' (#6155) from bp-v9.0/forgejo-216a542 into v9.0/forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6155 Reviewed-by: Otto <otto@codeberg.org>
This commit is contained in:
commit
8fa76300ae
2 changed files with 14 additions and 0 deletions
|
@ -63,6 +63,14 @@ func (g *GitHubLegacyCalloutTransformer) Transform(node *ast.Document, reader te
|
|||
attentionParagraph.AppendChild(attentionParagraph, calloutNode)
|
||||
firstParagraph.Parent().InsertBefore(firstParagraph.Parent(), firstParagraph, attentionParagraph)
|
||||
firstParagraph.RemoveChild(firstParagraph, calloutNode)
|
||||
|
||||
// Remove softbreak line if there's one.
|
||||
if firstParagraph.ChildCount() >= 1 {
|
||||
softBreakNode, ok := firstParagraph.FirstChild().(*ast.Text)
|
||||
if ok && softBreakNode.SoftLineBreak() {
|
||||
firstParagraph.RemoveChild(firstParagraph, softBreakNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ast.WalkContinue, nil
|
||||
|
|
|
@ -1356,4 +1356,10 @@ func TestCallout(t *testing.T) {
|
|||
}
|
||||
|
||||
test(">\n0", "<blockquote>\n</blockquote>\n<p>0</p>")
|
||||
test("> **Warning**\n> Bad stuff is brewing here", `<blockquote class="attention-header attention-warning"><p class="attention-title"><strong class="attention-warning">Warning</strong></p>
|
||||
<p>Bad stuff is brewing here</p>
|
||||
</blockquote>`)
|
||||
test("> [!WARNING]\n> Bad stuff is brewing here", `<blockquote class="attention-header attention-warning"><p class="attention-title"><strong class="attention-warning">Warning</strong></p>
|
||||
<p>Bad stuff is brewing here</p>
|
||||
</blockquote>`)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue