diff --git a/modules/markup/html.go b/modules/markup/html.go index 3355c021ce..ca9857d2bf 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -759,9 +759,6 @@ func shortLinkProcessor(ctx *RenderContext, node *html.Node) { title = path.Base(name) } alt := props["alt"] - if alt == "" { - alt = name - } // make the childNode an image - if we can, we also place the alt childNode.Type = html.ElementNode @@ -772,9 +769,6 @@ func shortLinkProcessor(ctx *RenderContext, node *html.Node) { {Key: "title", Val: title}, {Key: "alt", Val: alt}, } - if alt == "" { - childNode.Attr = childNode.Attr[:2] - } } else { if !absoluteLink { if ctx.IsWiki { diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index 05ba321548..6c00c5e7c8 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -416,7 +416,7 @@ func TestRender_ShortLinks(t *testing.T) { otherImgurlWiki := util.URLJoin(markup.TestRepoURL, "wiki", "raw", "Link+Other.jpg") encodedImgurlWiki := util.URLJoin(markup.TestRepoURL, "wiki", "raw", "Link+%23.jpg") notencodedImgurlWiki := util.URLJoin(markup.TestRepoURL, "wiki", "raw", "some", "path", "Link+#.jpg") - favicon := "http://google.com/favicon.ico" + favicon := "https://forgejo.org/favicon.ico" test( "[[Link]]", @@ -424,28 +424,28 @@ func TestRender_ShortLinks(t *testing.T) { `
`) test( "[[Link.jpg]]", - ``, - ``) + ``, + ``) test( "[["+favicon+"]]", - ``, - ``) + ``, + ``) test( "[[Name|Link]]", ``, ``) test( "[[Name|Link.jpg]]", - ``, - ``) + ``, + ``) test( "[[Name|Link.jpg|alt=AltName]]", ``, ``) test( "[[Name|Link.jpg|title=Title]]", - ``, - ``) + ``, + ``) test( "[[Name|Link.jpg|alt=AltName|title=Title]]", ``, @@ -472,16 +472,16 @@ func TestRender_ShortLinks(t *testing.T) { ``) test( "[[Link #.jpg]]", - ``, - ``) + ``, + ``) test( "[[Name|Link #.jpg|alt=\"AltName\"|title='Title']]", ``, ``) test( "[[some/path/Link #.jpg]]", - ``, - ``) + ``, + ``) test( "", ``, diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index 4c9ab42806..e64ab6a6f4 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -108,7 +108,7 @@ func TestRender_Images(t *testing.T) { test( "[["+title+"|"+url+"]]", - ``) + ``) test( "[]("+href+")", ``) @@ -119,7 +119,7 @@ func TestRender_Images(t *testing.T) { test( "[["+title+"|"+url+"]]", - ``) + ``) test( "[]("+href+")", ``) @@ -149,13 +149,13 @@ func testAnswers(baseURLContent, baseURLImages string) []string {![]() |
+![]() |
Installation |
---|---|---|
![]() |
+![]() |
Usage |