mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 03:18:24 +00:00 
			
		
		
		
	Update go-org to optimize code (#8824)
This commit is contained in:
		| @@ -8,7 +8,6 @@ import ( | ||||
| 	"bytes" | ||||
| 	"fmt" | ||||
| 	"html" | ||||
| 	"strings" | ||||
|  | ||||
| 	"code.gitea.io/gitea/modules/log" | ||||
| 	"code.gitea.io/gitea/modules/markup" | ||||
| @@ -91,7 +90,7 @@ func (r *Renderer) WriteRegularLink(l org.RegularLink) { | ||||
|  | ||||
| 	description := string(link) | ||||
| 	if l.Description != nil { | ||||
| 		description = r.nodesAsString(l.Description...) | ||||
| 		description = r.WriteNodesAsString(l.Description...) | ||||
| 	} | ||||
| 	switch l.Kind() { | ||||
| 	case "image": | ||||
| @@ -102,21 +101,3 @@ func (r *Renderer) WriteRegularLink(l org.RegularLink) { | ||||
| 		r.WriteString(fmt.Sprintf(`<a href="%s" title="%s">%s</a>`, link, description, description)) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (r *Renderer) emptyClone() *Renderer { | ||||
| 	wcopy := *(r.HTMLWriter) | ||||
| 	wcopy.Builder = strings.Builder{} | ||||
|  | ||||
| 	rcopy := *r | ||||
| 	rcopy.HTMLWriter = &wcopy | ||||
|  | ||||
| 	wcopy.ExtendingWriter = &rcopy | ||||
|  | ||||
| 	return &rcopy | ||||
| } | ||||
|  | ||||
| func (r *Renderer) nodesAsString(nodes ...org.Node) string { | ||||
| 	tmp := r.emptyClone() | ||||
| 	org.WriteNodes(tmp, nodes...) | ||||
| 	return tmp.String() | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user