diff --git a/modules/markup/html.go b/modules/markup/html.go index 8ce874074..dab6d4e8e 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -171,11 +171,6 @@ type postProcessCtx struct { // processors used by this context. procs []processor - - // if set to true, when an is found, instead of just returning during - // visitNode, it will recursively visit the node exclusively running - // shortLinkProcessorFull with true. - visitLinksForShortLinks bool } // PostProcess does the final required transformations to the passed raw HTML @@ -191,11 +186,10 @@ func PostProcess( ) ([]byte, error) { // create the context from the parameters ctx := &postProcessCtx{ - metas: metas, - urlPrefix: urlPrefix, - isWikiMarkdown: isWikiMarkdown, - procs: defaultProcessors, - visitLinksForShortLinks: true, + metas: metas, + urlPrefix: urlPrefix, + isWikiMarkdown: isWikiMarkdown, + procs: defaultProcessors, } return ctx.postProcess(rawHTML) } @@ -285,9 +279,6 @@ func (ctx *postProcessCtx) visitNode(node *html.Node) { ctx.textNode(node) case html.ElementNode: if node.Data == "a" || node.Data == "code" || node.Data == "pre" { - if node.Data == "a" && ctx.visitLinksForShortLinks { - ctx.visitNodeForShortLinks(node) - } return } for n := node.FirstChild; n != nil; n = n.NextSibling { @@ -302,7 +293,7 @@ func (ctx *postProcessCtx) visitNodeForShortLinks(node *html.Node) { case html.TextNode: shortLinkProcessorFull(ctx, node, true) case html.ElementNode: - if node.Data == "code" || node.Data == "pre" { + if node.Data == "code" || node.Data == "pre" || node.Data == "a" { return } for n := node.FirstChild; n != nil; n = n.NextSibling { diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index f17d00cd6..f430cb04b 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -222,4 +222,8 @@ func TestRender_ShortLinks(t *testing.T) { "[[some/path/Link #.jpg]]", `

`, `

`) + test( + "

[[foobar]]

", + `

[[foobar]]

`, + `

[[foobar]]

`) }