diff --git a/html.go b/html.go index abf8366..6cdab1c 100644 --- a/html.go +++ b/html.go @@ -387,32 +387,12 @@ func htmlListItem(out *bytes.Buffer, text []byte, flags int, opaque interface{}) } func htmlParagraph(out *bytes.Buffer, text []byte, opaque interface{}) { - options := opaque.(*htmlOptions) - if out.Len() > 0 { out.WriteByte('\n') } out.WriteString("

") - if options.flags&HTML_HARD_WRAP != 0 { - org := 0 - for i := 0; i < len(text); i++ { - if text[i] != '\n' { - continue - } - - if i > org { - out.Write(text[org:i]) - } - org = i - - out.WriteString("\n") } diff --git a/inline.go b/inline.go index 8fdf606..ae3fed1 100644 --- a/inline.go +++ b/inline.go @@ -157,9 +157,11 @@ func inlineCodeSpan(out *bytes.Buffer, rndr *render, data []byte, offset int) in } -// '\n' preceded by two spaces +// newline preceded by two spaces becomes
+// newline without two spaces works when EXTENSION_HARD_LINE_BREAK is enabled func inlineLineBreak(out *bytes.Buffer, rndr *render, data []byte, offset int) int { - if offset < 2 || data[offset-1] != ' ' || data[offset-2] != ' ' { + if rndr.flags&EXTENSION_HARD_LINE_BREAK == 0 && + (offset < 2 || data[offset-1] != ' ' || data[offset-2] != ' ') { return 0 } diff --git a/markdown.go b/markdown.go index eb7a07f..3c3f16c 100644 --- a/markdown.go +++ b/markdown.go @@ -27,6 +27,7 @@ const ( EXTENSION_STRIKETHROUGH EXTENSION_LAX_HTML_BLOCKS EXTENSION_SPACE_HEADERS + EXTENSION_HARD_LINE_BREAK ) // These are the possible flag values for the link renderer.