Skip to content

Commit d001a4c

Browse files
author
William Griffiths
committed
Add extra new line to seperate paragraphs.
1 parent a2eb234 commit d001a4c

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

html2text.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func HTML2Text(html string) string {
165165
outBuf.WriteString("\r\n")
166166
} else if tagName == "p" || tagName == "/p" {
167167
if canPrintNewline {
168-
outBuf.WriteString("\r\n")
168+
outBuf.WriteString("\r\n\r\n")
169169
}
170170
canPrintNewline = false
171171
} else if badTagnamesRE.MatchString(tagName) {

html2text_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestHTML2Text(t *testing.T) {
2323
Convey("Line breaks", func() {
2424
So(HTML2Text("should \nignore \r\nnew lines"), ShouldEqual, "should ignore new lines")
2525
So(HTML2Text(`two<br>line<br/>breaks`), ShouldEqual, "two\r\nline\r\nbreaks")
26-
So(HTML2Text(`<p>two</p><p>paragraphs</p>`), ShouldEqual, "two\r\nparagraphs")
26+
So(HTML2Text(`<p>two</p><p>paragraphs</p>`), ShouldEqual, "two\r\n\r\nparagraphs")
2727
})
2828

2929
Convey("HTML entities", func() {

0 commit comments

Comments
 (0)