diff --git a/pkg/renderer/sgml/html5/image.go b/pkg/renderer/sgml/html5/image.go index 4dbad557..0f38fd42 100644 --- a/pkg/renderer/sgml/html5/image.go +++ b/pkg/renderer/sgml/html5/image.go @@ -9,5 +9,5 @@ const ( {{ else }} {{ end }} ` - inlineImageTmpl = `{{ .Alt }}` + inlineImageTmpl = `{{ if ne .Href "" }}{{ end }}{{ .Alt }}{{ if ne .Href "" }}{{ end }}` ) diff --git a/pkg/renderer/sgml/html5/image_test.go b/pkg/renderer/sgml/html5/image_test.go index 3cc64f8c..eefcb331 100644 --- a/pkg/renderer/sgml/html5/image_test.go +++ b/pkg/renderer/sgml/html5/image_test.go @@ -214,6 +214,15 @@ image::appa.png[]` Expect(RenderHTML(source)).To(MatchHTML(expected)) }) + It("inline image with link", func() { + source := "image:foo.png[foo image, link=http://foo.bar]" + expected := `
+

foo image

+
+` + Expect(RenderHTML(source)).To(MatchHTML(expected)) + }) + It("paragraph with inline image with alt and dimensions", func() { source := "a foo image:foo.png[foo image, 600, 400] bar" expected := `
diff --git a/pkg/renderer/sgml/image.go b/pkg/renderer/sgml/image.go index bdf4d0b8..76f6793f 100644 --- a/pkg/renderer/sgml/image.go +++ b/pkg/renderer/sgml/image.go @@ -87,6 +87,7 @@ func (r *sgmlRenderer) renderInlineImage(img types.InlineImage) (string, error) }{ Title: r.renderElementTitle(img.Attributes), Roles: roles, + Href: img.Attributes.GetAsStringWithDefault(types.AttrInlineLink, ""), Alt: img.Attributes.GetAsStringWithDefault(types.AttrImageAlt, ""), Width: img.Attributes.GetAsStringWithDefault(types.AttrWidth, ""), Height: img.Attributes.GetAsStringWithDefault(types.AttrImageHeight, ""), diff --git a/pkg/renderer/sgml/xhtml5/image.go b/pkg/renderer/sgml/xhtml5/image.go index 00455b7d..21ddb7ca 100644 --- a/pkg/renderer/sgml/xhtml5/image.go +++ b/pkg/renderer/sgml/xhtml5/image.go @@ -15,9 +15,10 @@ const ( "
\n" inlineImageTmpl = `` + + `{{ if .Href }}{{ end }}` + `{{ .Alt }}` + `/>{{ if .Href }}{{ end }}` ) diff --git a/pkg/renderer/sgml/xhtml5/image_test.go b/pkg/renderer/sgml/xhtml5/image_test.go index 16bdfb29..26e80685 100644 --- a/pkg/renderer/sgml/xhtml5/image_test.go +++ b/pkg/renderer/sgml/xhtml5/image_test.go @@ -201,6 +201,15 @@ image::appa.png[]` Expect(RenderXHTML(source)).To(MatchHTML(expected)) }) + It("inline image with link", func() { + source := "image:foo.png[foo image, link=http://foo.bar]" + expected := `
+

foo image

+
+` + Expect(RenderXHTML(source)).To(MatchHTML(expected)) + }) + It("paragraph with inline image with alt and dimensions", func() { source := "a foo image:foo.png[foo image, 600, 400] bar" expected := `