From 175ebc6f88ae1f7ed19f28770622a21686f4ea81 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sat, 23 Oct 2021 23:30:46 +0800 Subject: [PATCH] Fix issue markdown bugs (#17413) * Bug fix: render Markdown `http://AppURL/org/repo/issues/4?a=1&b=2#comment-123 test` to HTML correctly, close #17394 * Bug fix: fix the positions of checkboxes in rendered HTML, close #17395 # Conflicts: # modules/markup/html.go --- modules/markup/html.go | 2 +- modules/markup/html_internal_test.go | 4 ++++ web_src/less/markup/content.less | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/markup/html.go b/modules/markup/html.go index d6a2571e2..1d5e9ccf2 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -92,7 +92,7 @@ func isLinkStr(link string) bool { func getIssueFullPattern() *regexp.Regexp { if issueFullPattern == nil { issueFullPattern = regexp.MustCompile(regexp.QuoteMeta(setting.AppURL) + - `\w+/\w+/(?:issues|pulls)/((?:\w{1,10}-)?[1-9][0-9]*)([\?|#]\S+.(\S+)?)?\b`) + `\w+/\w+/(?:issues|pulls)/((?:\w{1,10}-)?[1-9][0-9]*)([\?|#](\S+)?)?\b`) } return issueFullPattern } diff --git a/modules/markup/html_internal_test.go b/modules/markup/html_internal_test.go index dbad350de..f9ef90744 100644 --- a/modules/markup/html_internal_test.go +++ b/modules/markup/html_internal_test.go @@ -265,6 +265,10 @@ func TestRender_FullIssueURLs(t *testing.T) { `person/repo#4`) test("http://localhost:3000/gogits/gogs/issues/4", `#4`) + test("http://localhost:3000/gogits/gogs/issues/4 test", + `#4 test`) + test("http://localhost:3000/gogits/gogs/issues/4?a=1&b=2#comment-123 test", + `#4 test`) } func TestRegExp_sha1CurrentPattern(t *testing.T) { diff --git a/web_src/less/markup/content.less b/web_src/less/markup/content.less index df87c21d8..1678ff0fa 100644 --- a/web_src/less/markup/content.less +++ b/web_src/less/markup/content.less @@ -158,9 +158,12 @@ .task-list-item { list-style-type: none; + position: relative; input[type="checkbox"] { - margin: 0 6px .25em -1.6em; + position: absolute; + top: .25em; + left: -1.6em; } }