Update go-org to optimize code (#8824)
This commit is contained in:
parent
2f4ef84cbf
commit
05e7715c4b
19 changed files with 4824 additions and 113 deletions
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue