all repos — grayfriday @ c8f7e789d43d716164bea2fa6716380600b5a68f

blackfriday fork with a few changes

more robust whitespace stripping and matching corrections to tests
Russ Ross russ@russross.com
Mon, 27 Jun 2011 16:06:16 -0600
commit

c8f7e789d43d716164bea2fa6716380600b5a68f

parent

9a0217f7aa435282b4ba9139d9141bccca28ab05

M inline.goinline.go

@@ -154,18 +154,19 @@

// 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 rndr.flags&EXTENSION_HARD_LINE_BREAK == 0 && - (offset < 2 || data[offset-1] != ' ' || data[offset-2] != ' ') { - return 0 + // remove trailing spaces from out + outBytes := out.Bytes() + end := len(outBytes) + eol := end + for eol > 0 && (outBytes[eol-1] == ' ' || outBytes[eol-1] == '\t') { + eol-- } + out.Truncate(eol) - // remove trailing spaces from out and render - outBytes := out.Bytes() - end := len(outBytes) - for end > 0 && outBytes[end-1] == ' ' { - end-- + // should there be a hard line break here? + if rndr.flags&EXTENSION_HARD_LINE_BREAK == 0 && end-eol < 2 { + return 0 } - out.Truncate(end) if rndr.mk.LineBreak == nil { return 0
M inline_test.goinline_test.go

@@ -247,7 +247,7 @@ "this line \nhas a break\n",

"<p>this line<br />\nhas a break</p>\n", "this line \ndoes not\n", - "<p>this line \ndoes not</p>\n", + "<p>this line\ndoes not</p>\n", "this has an \nextra space\n", "<p>this has an<br />\nextra space</p>\n",
M upskirtref/Links, reference style.htmlupskirtref/Links, reference style.html

@@ -48,5 +48,5 @@

<p>Here's one where the <a href="/url/">link breaks</a> across lines.</p> -<p>Here's another where the <a href="/url/">link +<p>Here's another where the <a href="/url/">link breaks</a> across lines, but with a line-ending space.</p>
M upskirtref/Links, shortcut references.htmlupskirtref/Links, shortcut references.html

@@ -3,7 +3,7 @@

<p>This one has a <a href="/foo">line break</a>.</p> -<p>This one has a <a href="/foo">line +<p>This one has a <a href="/foo">line break</a> with a line-ending space.</p> <p><a href="/that">this</a> and the <a href="/other">other</a></p>