]> source.dussan.org Git - gitea.git/commitdiff
Fix markdown anchor links (#9673)
authorMoritz <13287984+mohe2015@users.noreply.github.com>
Thu, 16 Jan 2020 11:23:48 +0000 (12:23 +0100)
committerAntoine GIRARD <sapk@users.noreply.github.com>
Thu, 16 Jan 2020 11:23:48 +0000 (12:23 +0100)
Co-authored-by: Lauris BH <lauris@nix.lv>
modules/markup/markdown/goldmark.go

index 2a2a9dce6afb120900d795d23b8d7c6158f0fb82..a1c8e1ded0ec492d2449bce6388414e2128cbdea 100644 (file)
@@ -79,6 +79,9 @@ func (g *GiteaASTTransformer) Transform(node *ast.Document, reader text.Reader,
                                }
                                link = []byte(giteautil.URLJoin(pc.Get(urlPrefixKey).(string), lnk))
                        }
+                       if len(link) > 0 && link[0] == '#' {
+                               link = []byte("#user-content-" + string(link)[1:])
+                       }
                        v.Destination = link
                }
                return ast.WalkContinue, nil