diff --git a/modules/markup/markdown/callout/github_legacy.go b/modules/markup/markdown/callout/github_legacy.go index 32a278bc8d..96354b142b 100644 --- a/modules/markup/markdown/callout/github_legacy.go +++ b/modules/markup/markdown/callout/github_legacy.go @@ -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 diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index e3dc6c9655..cc2becad05 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -1356,4 +1356,10 @@ func TestCallout(t *testing.T) { } test(">\n0", "
\n\n
0
") + test("> **Warning**\n> Bad stuff is brewing here", ``) + test("> [!WARNING]\n> Bad stuff is brewing here", `Warning
+Bad stuff is brewing here
+
`) }Warning
+Bad stuff is brewing here
+