mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-04 01:34:27 +00:00 
			
		
		
		
	Refactor markup render system (#32612)
This PR removes (almost) all path tricks, and introduces "renderhelper" package. Now we can clearly see the rendering behaviors for comment/file/wiki, more details are in "renderhelper" tests. Fix #31411 , fix #18592, fix #25632 and maybe more problems. (ps: fix #32608 by the way)
This commit is contained in:
		@@ -4,8 +4,6 @@
 | 
			
		||||
package markup
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"code.gitea.io/gitea/modules/util"
 | 
			
		||||
 | 
			
		||||
	"golang.org/x/net/html"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -17,7 +15,7 @@ func visitNodeImg(ctx *RenderContext, img *html.Node) (next *html.Node) {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if IsNonEmptyRelativePath(attr.Val) {
 | 
			
		||||
			attr.Val = util.URLJoin(ctx.RenderOptions.Links.ResolveMediaLink(ctx.IsMarkupContentWiki()), attr.Val)
 | 
			
		||||
			attr.Val = ctx.RenderHelper.ResolveLink(attr.Val, LinkTypeMedia)
 | 
			
		||||
 | 
			
		||||
			// By default, the "<img>" tag should also be clickable,
 | 
			
		||||
			// because frontend use `<img>` to paste the re-scaled image into the markdown,
 | 
			
		||||
@@ -53,7 +51,7 @@ func visitNodeVideo(ctx *RenderContext, node *html.Node) (next *html.Node) {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		if IsNonEmptyRelativePath(attr.Val) {
 | 
			
		||||
			attr.Val = util.URLJoin(ctx.RenderOptions.Links.ResolveMediaLink(ctx.IsMarkupContentWiki()), attr.Val)
 | 
			
		||||
			attr.Val = ctx.RenderHelper.ResolveLink(attr.Val, LinkTypeMedia)
 | 
			
		||||
		}
 | 
			
		||||
		attr.Val = camoHandleLink(attr.Val)
 | 
			
		||||
		node.Attr[i] = attr
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user