diff --git a/markdown/extender.go b/markdown/extender.go index 395e116..6fb9bdf 100644 --- a/markdown/extender.go +++ b/markdown/extender.go @@ -173,10 +173,12 @@ func (r *nodeRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer) { } n := node.(*ast.Text) + if n.SoftLineBreak() { + defer func() { _ = w.WriteByte('\n') }() + } + text := n.Text(source) if len(text) == 0 { - // Simply write a line break if there is no text in the node, otherwise, soft break lines are sticking. - _ = w.WriteByte('\n') return ast.WalkContinue, nil } diff --git a/markdown/markdown_test.go b/markdown/markdown_test.go index 96f1dac..4a75dfd 100644 --- a/markdown/markdown_test.go +++ b/markdown/markdown_test.go @@ -134,8 +134,7 @@ func TestRenderer(t *testing.T) { if err != nil { t.Fatal(err) } - want := `

a -

+ want := `

a

` if string(doc.HTML) != want { t.Errorf("got %q, want %q", string(doc.HTML), want)