diff --git a/modules/markup/orgmode/orgmode.go b/modules/markup/orgmode/orgmode.go index 9b6175649f..c1e0144199 100644 --- a/modules/markup/orgmode/orgmode.go +++ b/modules/markup/orgmode/orgmode.go @@ -158,7 +158,7 @@ func (r *Writer) WriteRegularLink(l org.RegularLink) { case "image": if l.Description == nil { imageSrc := getMediaURL(link) - fmt.Fprintf(r, ``, imageSrc, link, link) + fmt.Fprintf(r, ``, imageSrc, link) } else { description := strings.TrimPrefix(org.String(l.Description...), "file:") imageSrc := getMediaURL([]byte(description)) @@ -167,18 +167,18 @@ func (r *Writer) WriteRegularLink(l org.RegularLink) { case "video": if l.Description == nil { imageSrc := getMediaURL(link) - fmt.Fprintf(r, ``, imageSrc, link, link) + fmt.Fprintf(r, ``, imageSrc, link) } else { description := strings.TrimPrefix(org.String(l.Description...), "file:") videoSrc := getMediaURL([]byte(description)) - fmt.Fprintf(r, ``, link, videoSrc, videoSrc) + fmt.Fprintf(r, ``, link, videoSrc, videoSrc) } default: description := string(link) if l.Description != nil { description = r.WriteNodesAsString(l.Description...) } - fmt.Fprintf(r, `%s`, link, description, description) + fmt.Fprintf(r, `%s`, link, description) } } diff --git a/modules/markup/orgmode/orgmode_test.go b/modules/markup/orgmode/orgmode_test.go index 8f454e9955..88ae14ebcf 100644 --- a/modules/markup/orgmode/orgmode_test.go +++ b/modules/markup/orgmode/orgmode_test.go @@ -34,12 +34,12 @@ func TestRender_StandardLinks(t *testing.T) { assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer)) } - googleRendered := "
" - test("[[https://google.com/]]", googleRendered) + test("[[https://google.com/]]", + ``) lnk := util.URLJoin(AppSubURL, "WikiPage") test("[[WikiPage][WikiPage]]", - "") + ``) } func TestRender_Media(t *testing.T) { @@ -59,19 +59,23 @@ func TestRender_Media(t *testing.T) { result := util.URLJoin(AppSubURL, url) test("[[file:"+url+"]]", - "") + ``) // With description. test("[[https://example.com][https://example.com/example.svg]]", ``) + test("[[https://example.com][pre https://example.com/example.svg post]]", + ``) test("[[https://example.com][https://example.com/example.mp4]]", - ``) + ``) + test("[[https://example.com][pre https://example.com/example.mp4 post]]", + ``) // Without description. test("[[https://example.com/example.svg]]", - ``) + ``) test("[[https://example.com/example.mp4]]", - ``) + ``) } func TestRender_Source(t *testing.T) {