all repos — grayfriday @ 18186eea26bace1358b1a5b940e2284c84dd2741

blackfriday fork with a few changes

Do not emit newline after <img> tag.

This changes HTML renderer not to always add a newline character after
<img> tags. This is desirable because <img> tags can be inlined, and
sometimes you want to avoid whitespace on left and right sides. Previous
behavior of always adding a newline would unavoidably create whitespace
after <img> tag.

Update all tests to match new behavior. There are few changes, and
they're completely isolated to inline image tests.

Fixes #169.
Dmitri Shuralyov shurcooL@gmail.com
Mon, 25 May 2015 12:41:06 -0700
commit

18186eea26bace1358b1a5b940e2284c84dd2741

parent

10880f66e2cfd97fe5998a4279706320b5ff5167

2 files changed, 12 insertions(+), 11 deletions(-)

jump to
M html.gohtml.go

@@ -76,7 +76,7 @@ //

// Do not create this directly, instead use the HtmlRenderer function. type Html struct { flags int // HTML_* options - closeTag string // how to end singleton tags: either " />\n" or ">\n" + closeTag string // how to end singleton tags: either " />" or ">" title string // document title css string // optional css file url (used with HTML_COMPLETE_PAGE)

@@ -95,8 +95,8 @@ smartypants *smartypantsRenderer

} const ( - xhtmlClose = " />\n" - htmlClose = ">\n" + xhtmlClose = " />" + htmlClose = ">" ) // HtmlRenderer creates and configures an Html object, which

@@ -250,6 +250,7 @@ func (options *Html) HRule(out *bytes.Buffer) {

doubleSpace(out) out.WriteString("<hr") out.WriteString(options.closeTag) + out.WriteByte('\n') } func (options *Html) BlockCode(out *bytes.Buffer, text []byte, lang string) {

@@ -512,12 +513,12 @@ }

out.WriteByte('"') out.WriteString(options.closeTag) - return } func (options *Html) LineBreak(out *bytes.Buffer) { out.WriteString("<br") out.WriteString(options.closeTag) + out.WriteByte('\n') } func (options *Html) Link(out *bytes.Buffer, link []byte, title []byte, content []byte) {
M inline_test.goinline_test.go

@@ -441,22 +441,22 @@ "[foo]()\n",

"<p>[foo]()</p>\n", "![foo](/bar/)\n", - "<p><img src=\"/bar/\" alt=\"foo\" />\n</p>\n", + "<p><img src=\"/bar/\" alt=\"foo\" /></p>\n", "![foo with a title](/bar/ \"title\")\n", - "<p><img src=\"/bar/\" alt=\"foo with a title\" title=\"title\" />\n</p>\n", + "<p><img src=\"/bar/\" alt=\"foo with a title\" title=\"title\" /></p>\n", "![foo with a title](/bar/\t\"title\")\n", - "<p><img src=\"/bar/\" alt=\"foo with a title\" title=\"title\" />\n</p>\n", + "<p><img src=\"/bar/\" alt=\"foo with a title\" title=\"title\" /></p>\n", "![foo with a title](/bar/ \"title\" )\n", - "<p><img src=\"/bar/\" alt=\"foo with a title\" title=\"title\" />\n</p>\n", + "<p><img src=\"/bar/\" alt=\"foo with a title\" title=\"title\" /></p>\n", "![foo with a title](/bar/ title with no quotes)\n", - "<p><img src=\"/bar/ title with no quotes\" alt=\"foo with a title\" />\n</p>\n", + "<p><img src=\"/bar/ title with no quotes\" alt=\"foo with a title\" /></p>\n", "![](img.jpg)\n", - "<p><img src=\"img.jpg\" alt=\"\" />\n</p>\n", + "<p><img src=\"img.jpg\" alt=\"\" /></p>\n", "[link](url)\n", "<p><a href=\"url\">link</a></p>\n",

@@ -501,7 +501,7 @@ "[link]( with whitespace )\n",

"<p><a href=\"with whitespace\">link</a></p>\n", "[![image](someimage)](with image)\n", - "<p><a href=\"with image\"><img src=\"someimage\" alt=\"image\" />\n</a></p>\n", + "<p><a href=\"with image\"><img src=\"someimage\" alt=\"image\" /></a></p>\n", "[link](url \"one quote)\n", "<p><a href=\"url &quot;one quote\">link</a></p>\n",