mirror of
https://github.com/danog/blackfriday.git
synced 2025-01-22 21:31:20 +01:00
Merge pull request #170 from russross/no-newline-after-img
Do not emit newline after <img> tag.
This commit is contained in:
commit
93ae1e873a
9
html.go
9
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("<hr")
|
||||
out.WriteString(options.closeTag)
|
||||
out.WriteByte('\n')
|
||||
}
|
||||
|
||||
func (options *Html) BlockCode(out *bytes.Buffer, text []byte, lang string) {
|
||||
@ -512,12 +513,12 @@ func (options *Html) Image(out *bytes.Buffer, link []byte, title []byte, alt []b
|
||||
|
||||
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) {
|
||||
|
@ -441,22 +441,22 @@ func TestInlineLink(t *testing.T) {
|
||||
"<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 @@ func TestInlineLink(t *testing.T) {
|
||||
"<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 "one quote\">link</a></p>\n",
|
||||
|
Loading…
x
Reference in New Issue
Block a user