From 18186eea26bace1358b1a5b940e2284c84dd2741 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Mon, 25 May 2015 12:41:06 -0700 Subject: [PATCH] Do not emit newline after tag. This changes HTML renderer not to always add a newline character after tags. This is desirable because 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 tag. Update all tests to match new behavior. There are few changes, and they're completely isolated to inline image tests. Fixes #169. --- html.go | 9 +++++---- inline_test.go | 14 +++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/html.go b/html.go index 1b78769..4c31cac 100644 --- a/html.go +++ b/html.go @@ -76,7 +76,7 @@ type HtmlRendererParameters struct { // 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 @@ type Html struct { } 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("[foo]()

\n", "![foo](/bar/)\n", - "

\"foo\"\n

\n", + "

\"foo\"

\n", "![foo with a title](/bar/ \"title\")\n", - "

\"foo\n

\n", + "

\"foo

\n", "![foo with a title](/bar/\t\"title\")\n", - "

\"foo\n

\n", + "

\"foo

\n", "![foo with a title](/bar/ \"title\" )\n", - "

\"foo\n

\n", + "

\"foo

\n", "![foo with a title](/bar/ title with no quotes)\n", - "

\"foo\n

\n", + "

\"foo

\n", "![](img.jpg)\n", - "

\"\"\n

\n", + "

\"\"

\n", "[link](url)\n", "

link

\n", @@ -501,7 +501,7 @@ func TestInlineLink(t *testing.T) { "

link

\n", "[![image](someimage)](with image)\n", - "

\"image\"\n

\n", + "

\"image\"

\n", "[link](url \"one quote)\n", "

link

\n",