all repos — grayfriday @ f5e3dc8073dcaef4a37da1bfee94d67f0866bd3c

blackfriday fork with a few changes

refactoring: newlines as hard breaks changed from HTML option to global markdown option
Russ Ross russ@russross.com
Sat, 25 Jun 2011 15:45:51 -0600
commit

f5e3dc8073dcaef4a37da1bfee94d67f0866bd3c

parent

812e8d01851b51ca99a3d0dae135b059823c2b03

3 files changed, 6 insertions(+), 23 deletions(-)

jump to
M html.gohtml.go

@@ -387,32 +387,12 @@ out.WriteString("</li>\n")

} func htmlParagraph(out *bytes.Buffer, text []byte, opaque interface{}) { - options := opaque.(*htmlOptions) - if out.Len() > 0 { out.WriteByte('\n') } out.WriteString("<p>") - 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("<br") - out.WriteString(options.closeTag) - } - out.Write(text[org:]) - } else { - out.Write(text) - } + out.Write(text) out.WriteString("</p>\n") }
M inline.goinline.go

@@ -157,9 +157,11 @@ return end

} -// '\n' preceded by two spaces +// newline preceded by two spaces becomes <br> +// 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 }
M markdown.gomarkdown.go

@@ -27,6 +27,7 @@ EXTENSION_AUTOLINK

EXTENSION_STRIKETHROUGH EXTENSION_LAX_HTML_BLOCKS EXTENSION_SPACE_HEADERS + EXTENSION_HARD_LINE_BREAK ) // These are the possible flag values for the link renderer.