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) { `

Link

`) test( "[[Link.jpg]]", - `

Link.jpg

`, - `

Link.jpg

`) + `

`, + `

`) test( "[["+favicon+"]]", - `

`+favicon+`

`, - `

`+favicon+`

`) + `

`, + `

`) test( "[[Name|Link]]", `

Name

`, `

Name

`) test( "[[Name|Link.jpg]]", - `

Name

`, - `

Name

`) + `

`, + `

`) test( "[[Name|Link.jpg|alt=AltName]]", `

AltName

`, `

AltName

`) test( "[[Name|Link.jpg|title=Title]]", - `

Title

`, - `

Title

`) + `

`, + `

`) test( "[[Name|Link.jpg|alt=AltName|title=Title]]", `

AltName

`, @@ -472,16 +472,16 @@ func TestRender_ShortLinks(t *testing.T) { `

Link Other Link Link?

`) test( "[[Link #.jpg]]", - `

Link #.jpg

`, - `

Link #.jpg

`) + `

`, + `

`) test( "[[Name|Link #.jpg|alt=\"AltName\"|title='Title']]", `

AltName

`, `

AltName

`) test( "[[some/path/Link #.jpg]]", - `

some/path/Link #.jpg

`, - `

some/path/Link #.jpg

`) + `

`, + `

`) test( "

[[foobar]]

", `

[[foobar]]

`, 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+"]]", - `

`+title+`

`) + `

`) test( "[!["+title+"]("+url+")]("+href+")", `

`+title+`

`) @@ -119,7 +119,7 @@ func TestRender_Images(t *testing.T) { test( "[["+title+"|"+url+"]]", - `

`+title+`

`) + `

`) test( "[!["+title+"]("+url+")]("+href+")", `

`+title+`

`) @@ -149,13 +149,13 @@ func testAnswers(baseURLContent, baseURLImages string) []string { - + - + @@ -164,9 +164,9 @@ func testAnswers(baseURLContent, baseURLImages string) []string { `

Excelsior JET allows you to create native executables for Windows, Linux and Mac OS X.

  1. Package your libGDX application
    -images/1.png
  2. +
  3. Perform a test run by hitting the Run! button.
    -images/2.png
  4. +

More tests

(from https://www.markdownguide.org/extended-syntax/)

@@ -849,8 +849,8 @@ mail@domain.com local image
local image
remote image
-local image
-remote link
+
+
https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
@@ -876,8 +876,8 @@ space

local image
local image
remote image
-local image
-remote link
+
+
https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
@@ -905,8 +905,8 @@ space

local image
local image
remote image
-local image
-remote link
+
+
https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
@@ -934,8 +934,8 @@ space

local image
local image
remote image
-local image
-remote link
+
+
https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
@@ -963,8 +963,8 @@ space

local image
local image
remote image
-local image
-remote link
+
+
https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
@@ -992,8 +992,8 @@ space

local image
local image
remote image
-local image
-remote link
+
+
https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
@@ -1022,8 +1022,8 @@ space

local image
local image
remote image
-local image
-remote link
+
+
https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
@@ -1052,8 +1052,8 @@ space

local image
local image
remote image
-local image
-remote link
+
+
https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
@@ -1082,8 +1082,8 @@ space

local image
local image
remote image
-local image
-remote link
+
+
https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
@@ -1112,8 +1112,8 @@ space

local image
local image
remote image
-local image
-remote link
+
+
https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
@@ -1143,8 +1143,8 @@ space

local image
local image
remote image
-local image
-remote link
+
+
https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
@@ -1174,8 +1174,8 @@ space

local image
local image
remote image
-local image
-remote link
+
+
https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
diff --git a/modules/templates/util_avatar.go b/modules/templates/util_avatar.go index afc1091516..a468361101 100644 --- a/modules/templates/util_avatar.go +++ b/modules/templates/util_avatar.go @@ -34,7 +34,7 @@ func AvatarHTML(src string, size int, class, name string) template.HTML { name = "avatar" } - return template.HTML(``) + return template.HTML(``) } // Avatar renders user avatars. args: user, size (int), class (string) diff --git a/modules/templates/util_render_test.go b/modules/templates/util_render_test.go index 3479d94039..028cd2ba76 100644 --- a/modules/templates/util_render_test.go +++ b/modules/templates/util_render_test.go @@ -194,8 +194,8 @@ func TestRenderMarkdownToHtml(t *testing.T) { remote linklocal imageremote image -local image -remote link + +88fc37a3c0...12fc37a3c0 (hash) com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare 88fc37a3c0 diff --git a/routers/api/v1/misc/markup_test.go b/routers/api/v1/misc/markup_test.go index df70ee49ef..32568b805f 100644 --- a/routers/api/v1/misc/markup_test.go +++ b/routers/api/v1/misc/markup_test.go @@ -112,7 +112,7 @@ Here are some links to the most important topics. You can find the full list of

Here are some links to the most important topics. You can find the full list of pages at the sidebar.

Configuration -images/icon-bug.png

+

`, } diff --git a/templates/install.tmpl b/templates/install.tmpl index ae800df130..7a9b40826f 100644 --- a/templates/install.tmpl +++ b/templates/install.tmpl @@ -363,5 +363,5 @@ - +{{ctx.Locale.Tr {{template "base/footer" .}} diff --git a/templates/repo/diff/image_diff.tmpl b/templates/repo/diff/image_diff.tmpl index 0612854609..a793f54da1 100644 --- a/templates/repo/diff/image_diff.tmpl +++ b/templates/repo/diff/image_diff.tmpl @@ -22,7 +22,7 @@ {{if .blobBase}}

{{ctx.Locale.Tr "repo.diff.file_before"}}

- +

{{ctx.Locale.Tr "repo.diff.file_image_width"}}: @@ -37,7 +37,7 @@ {{if .blobHead}}

{{ctx.Locale.Tr "repo.diff.file_after"}}

- +

{{ctx.Locale.Tr "repo.diff.file_image_width"}}: @@ -55,9 +55,9 @@

- + {{ctx.Locale.Tr - + {{ctx.Locale.Tr @@ -70,8 +70,8 @@
- - + {{ctx.Locale.Tr + {{ctx.Locale.Tr
diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index c8eabb9345..604efed737 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -602,7 +602,7 @@
- + {{svg "octicon-x" 16}} diff --git a/templates/repo/migrate/migrating.tmpl b/templates/repo/migrate/migrating.tmpl index 0b53636160..3a6bb25879 100644 --- a/templates/repo/migrate/migrating.tmpl +++ b/templates/repo/migrate/migrating.tmpl @@ -9,7 +9,7 @@
- + {{ctx.Locale.Tr
diff --git a/templates/repo/settings/lfs_file.tmpl b/templates/repo/settings/lfs_file.tmpl index 5bcd2af5bf..941d09f3e6 100644 --- a/templates/repo/settings/lfs_file.tmpl +++ b/templates/repo/settings/lfs_file.tmpl @@ -21,7 +21,7 @@ {{else if not .IsTextFile}}
{{if .IsImageFile}} - + {{else if .IsVideoFile}}
images/icon-install.png Installation
images/icon-usage.png Usage