From 6442ae1259e3faf5a152f541c406f0e591793952 Mon Sep 17 00:00:00 2001 From: yuin Date: Sat, 14 Oct 2023 18:02:09 +0900 Subject: [PATCH] Fix #416 --- _test/extra.txt | 9 +++++++++ renderer/html/html.go | 3 +++ 2 files changed, 12 insertions(+) diff --git a/_test/extra.txt b/_test/extra.txt index ceaf432..742777a 100644 --- a/_test/extra.txt +++ b/_test/extra.txt @@ -771,3 +771,12 @@ a

<img src=./.assets/logo.svg

/>

//= = = = = = = = = = = = = = = = = = = = = = = =// + +61: Image alt with a new line +//- - - - - - - - -// +![alt +text](logo.png) +//- - - - - - - - -// +

alt
+text

+//= = = = = = = = = = = = = = = = = = = = = = = =// diff --git a/renderer/html/html.go b/renderer/html/html.go index 3503688..1241a0b 100644 --- a/renderer/html/html.go +++ b/renderer/html/html.go @@ -938,6 +938,9 @@ func nodeToHTMLText(n ast.Node, source []byte) []byte { buf.Write(s.Text(source)) } else if !c.HasChildren() { buf.Write(util.EscapeHTML(c.Text(source))) + if t, ok := c.(*ast.Text); ok && t.SoftLineBreak() { + buf.WriteByte('\n') + } } else { buf.Write(nodeToHTMLText(c, source)) }