From 05e7715c4b2af174aefc56fe459e5c08a96a3017 Mon Sep 17 00:00:00 2001 From: Lauris BH Date: Tue, 5 Nov 2019 10:39:03 +0200 Subject: Update go-org to optimize code (#8824) --- modules/markup/orgmode/orgmode.go | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'modules') diff --git a/modules/markup/orgmode/orgmode.go b/modules/markup/orgmode/orgmode.go index 54188d2734..86222cc88e 100644 --- a/modules/markup/orgmode/orgmode.go +++ b/modules/markup/orgmode/orgmode.go @@ -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(`%s`, 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() -} -- cgit v1.2.3