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
4
go.mod
4
go.mod
|
@ -72,7 +72,7 @@ require (
|
||||||
github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae // indirect
|
github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae // indirect
|
||||||
github.com/msteinert/pam v0.0.0-20151204160544-02ccfbfaf0cc
|
github.com/msteinert/pam v0.0.0-20151204160544-02ccfbfaf0cc
|
||||||
github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5
|
github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5
|
||||||
github.com/niklasfasching/go-org v0.1.7
|
github.com/niklasfasching/go-org v0.1.8
|
||||||
github.com/oliamb/cutter v0.2.2
|
github.com/oliamb/cutter v0.2.2
|
||||||
github.com/philhofer/fwd v1.0.0 // indirect
|
github.com/philhofer/fwd v1.0.0 // indirect
|
||||||
github.com/pkg/errors v0.8.1
|
github.com/pkg/errors v0.8.1
|
||||||
|
@ -101,7 +101,7 @@ require (
|
||||||
github.com/willf/bitset v0.0.0-20180426185212-8ce1146b8621 // indirect
|
github.com/willf/bitset v0.0.0-20180426185212-8ce1146b8621 // indirect
|
||||||
github.com/yohcop/openid-go v0.0.0-20160914080427-2c050d2dae53
|
github.com/yohcop/openid-go v0.0.0-20160914080427-2c050d2dae53
|
||||||
golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad
|
golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad
|
||||||
golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271
|
golang.org/x/net v0.0.0-20191101175033-0deb6923b6d9
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
||||||
golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b
|
golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b
|
||||||
golang.org/x/text v0.3.2
|
golang.org/x/text v0.3.2
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -427,6 +427,8 @@ github.com/niklasfasching/go-org v0.1.6 h1:F521WcqRNl8OJumlgAnekZgERaTA2HpfOYYfV
|
||||||
github.com/niklasfasching/go-org v0.1.6/go.mod h1:AsLD6X7djzRIz4/RFZu8vwRL0VGjUvGZCCH1Nz0VdrU=
|
github.com/niklasfasching/go-org v0.1.6/go.mod h1:AsLD6X7djzRIz4/RFZu8vwRL0VGjUvGZCCH1Nz0VdrU=
|
||||||
github.com/niklasfasching/go-org v0.1.7 h1:t3V+3XnS/7BhKv/7SlMUa8FvAiq577/a1T3D7mLIRXE=
|
github.com/niklasfasching/go-org v0.1.7 h1:t3V+3XnS/7BhKv/7SlMUa8FvAiq577/a1T3D7mLIRXE=
|
||||||
github.com/niklasfasching/go-org v0.1.7/go.mod h1:AsLD6X7djzRIz4/RFZu8vwRL0VGjUvGZCCH1Nz0VdrU=
|
github.com/niklasfasching/go-org v0.1.7/go.mod h1:AsLD6X7djzRIz4/RFZu8vwRL0VGjUvGZCCH1Nz0VdrU=
|
||||||
|
github.com/niklasfasching/go-org v0.1.8 h1:Kjvs6lP+LIILHhc9zIJ4Gu90a/pVY483if2Qmu8v4Fg=
|
||||||
|
github.com/niklasfasching/go-org v0.1.8/go.mod h1:AsLD6X7djzRIz4/RFZu8vwRL0VGjUvGZCCH1Nz0VdrU=
|
||||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||||
github.com/oliamb/cutter v0.2.2 h1:Lfwkya0HHNU1YLnGv2hTkzHfasrSMkgv4Dn+5rmlk3k=
|
github.com/oliamb/cutter v0.2.2 h1:Lfwkya0HHNU1YLnGv2hTkzHfasrSMkgv4Dn+5rmlk3k=
|
||||||
github.com/oliamb/cutter v0.2.2/go.mod h1:4BenG2/4GuRBDbVm/OPahDVqbrOemzpPiG5mi1iryBU=
|
github.com/oliamb/cutter v0.2.2/go.mod h1:4BenG2/4GuRBDbVm/OPahDVqbrOemzpPiG5mi1iryBU=
|
||||||
|
@ -658,6 +660,8 @@ golang.org/x/net v0.0.0-20190909003024-a7b16738d86b h1:XfVGCX+0T4WOStkaOsJRllbsi
|
||||||
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271 h1:N66aaryRB3Ax92gH0v3hp1QYZ3zWWCCUR/j8Ifh45Ss=
|
golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271 h1:N66aaryRB3Ax92gH0v3hp1QYZ3zWWCCUR/j8Ifh45Ss=
|
||||||
golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20191101175033-0deb6923b6d9 h1:DPz9iiH3YoKiKhX/ijjoZvT0VFwK2c6CWYWQ7Zyr8TU=
|
||||||
|
golang.org/x/net v0.0.0-20191101175033-0deb6923b6d9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/oauth2 v0.0.0-20180620175406-ef147856a6dd/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180620175406-ef147856a6dd/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 h1:Wo7BWFiOk0QRFMLYMqJGFMd9CgUAcGx7V+qEg/h5IBI=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 h1:Wo7BWFiOk0QRFMLYMqJGFMd9CgUAcGx7V+qEg/h5IBI=
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/markup"
|
"code.gitea.io/gitea/modules/markup"
|
||||||
|
@ -91,7 +90,7 @@ func (r *Renderer) WriteRegularLink(l org.RegularLink) {
|
||||||
|
|
||||||
description := string(link)
|
description := string(link)
|
||||||
if l.Description != nil {
|
if l.Description != nil {
|
||||||
description = r.nodesAsString(l.Description...)
|
description = r.WriteNodesAsString(l.Description...)
|
||||||
}
|
}
|
||||||
switch l.Kind() {
|
switch l.Kind() {
|
||||||
case "image":
|
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))
|
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()
|
|
||||||
}
|
|
||||||
|
|
4
vendor/github.com/niklasfasching/go-org/org/block.go
generated
vendored
4
vendor/github.com/niklasfasching/go-org/org/block.go
generated
vendored
|
@ -80,5 +80,5 @@ func trimIndentUpTo(max int) func(string) string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n Example) String() string { return orgWriter.nodesAsString(n) }
|
func (n Example) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n Block) String() string { return orgWriter.nodesAsString(n) }
|
func (n Block) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
|
|
2
vendor/github.com/niklasfasching/go-org/org/document.go
generated
vendored
2
vendor/github.com/niklasfasching/go-org/org/document.go
generated
vendored
|
@ -90,7 +90,7 @@ func New() *Configuration {
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns the pretty printed Org mode string for the given nodes (see OrgWriter).
|
// String returns the pretty printed Org mode string for the given nodes (see OrgWriter).
|
||||||
func String(nodes []Node) string { return orgWriter.nodesAsString(nodes...) }
|
func String(nodes []Node) string { return orgWriter.WriteNodesAsString(nodes...) }
|
||||||
|
|
||||||
// Write is called after with an instance of the Writer interface to export a parsed Document into another format.
|
// Write is called after with an instance of the Writer interface to export a parsed Document into another format.
|
||||||
func (d *Document) Write(w Writer) (out string, err error) {
|
func (d *Document) Write(w Writer) (out string, err error) {
|
||||||
|
|
4
vendor/github.com/niklasfasching/go-org/org/drawer.go
generated
vendored
4
vendor/github.com/niklasfasching/go-org/org/drawer.go
generated
vendored
|
@ -93,5 +93,5 @@ func (d *PropertyDrawer) Get(key string) (string, bool) {
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n Drawer) String() string { return orgWriter.nodesAsString(n) }
|
func (n Drawer) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n PropertyDrawer) String() string { return orgWriter.nodesAsString(n) }
|
func (n PropertyDrawer) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
|
|
2
vendor/github.com/niklasfasching/go-org/org/footnote.go
generated
vendored
2
vendor/github.com/niklasfasching/go-org/org/footnote.go
generated
vendored
|
@ -32,4 +32,4 @@ func (d *Document) parseFootnoteDefinition(i int, parentStop stopFn) (int, Node)
|
||||||
return consumed, definition
|
return consumed, definition
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n FootnoteDefinition) String() string { return orgWriter.nodesAsString(n) }
|
func (n FootnoteDefinition) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
|
|
2
vendor/github.com/niklasfasching/go-org/org/headline.go
generated
vendored
2
vendor/github.com/niklasfasching/go-org/org/headline.go
generated
vendored
|
@ -98,4 +98,4 @@ func (parent *Section) add(current *Section) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n Headline) String() string { return orgWriter.nodesAsString(n) }
|
func (n Headline) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
|
|
39
vendor/github.com/niklasfasching/go-org/org/html_writer.go
generated
vendored
39
vendor/github.com/niklasfasching/go-org/org/html_writer.go
generated
vendored
|
@ -69,16 +69,13 @@ func NewHTMLWriter() *HTMLWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *HTMLWriter) emptyClone() *HTMLWriter {
|
func (w *HTMLWriter) WriteNodesAsString(nodes ...Node) string {
|
||||||
wcopy := *w
|
original := w.Builder
|
||||||
wcopy.Builder = strings.Builder{}
|
w.Builder = strings.Builder{}
|
||||||
return &wcopy
|
WriteNodes(w, nodes...)
|
||||||
}
|
out := w.String()
|
||||||
|
w.Builder = original
|
||||||
func (w *HTMLWriter) nodesAsString(nodes ...Node) string {
|
return out
|
||||||
tmp := w.emptyClone()
|
|
||||||
WriteNodes(tmp, nodes...)
|
|
||||||
return tmp.String()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *HTMLWriter) WriterWithExtensions() Writer {
|
func (w *HTMLWriter) WriterWithExtensions() Writer {
|
||||||
|
@ -104,12 +101,14 @@ func (w *HTMLWriter) WritePropertyDrawer(PropertyDrawer) {}
|
||||||
func (w *HTMLWriter) WriteBlock(b Block) {
|
func (w *HTMLWriter) WriteBlock(b Block) {
|
||||||
content := ""
|
content := ""
|
||||||
if isRawTextBlock(b.Name) {
|
if isRawTextBlock(b.Name) {
|
||||||
exportWriter := w.emptyClone()
|
builder, htmlEscape := w.Builder, w.htmlEscape
|
||||||
exportWriter.htmlEscape = false
|
w.Builder, w.htmlEscape = strings.Builder{}, false
|
||||||
WriteNodes(exportWriter, b.Children...)
|
WriteNodes(w, b.Children...)
|
||||||
content = strings.TrimRightFunc(exportWriter.String(), unicode.IsSpace)
|
out := w.String()
|
||||||
|
w.Builder, w.htmlEscape = builder, htmlEscape
|
||||||
|
content = strings.TrimRightFunc(out, unicode.IsSpace)
|
||||||
} else {
|
} else {
|
||||||
content = w.nodesAsString(b.Children...)
|
content = w.WriteNodesAsString(b.Children...)
|
||||||
}
|
}
|
||||||
switch name := b.Name; {
|
switch name := b.Name; {
|
||||||
case name == "SRC":
|
case name == "SRC":
|
||||||
|
@ -194,7 +193,7 @@ func (w *HTMLWriter) writeSection(section *Section) {
|
||||||
// NOTE: To satisfy hugo ExtractTOC() check we cannot use `<li>\n` here. Doesn't really matter, just a note.
|
// NOTE: To satisfy hugo ExtractTOC() check we cannot use `<li>\n` here. Doesn't really matter, just a note.
|
||||||
w.WriteString("<li>")
|
w.WriteString("<li>")
|
||||||
h := section.Headline
|
h := section.Headline
|
||||||
title := cleanHeadlineTitleForHTMLAnchorRegexp.ReplaceAllString(w.nodesAsString(h.Title...), "")
|
title := cleanHeadlineTitleForHTMLAnchorRegexp.ReplaceAllString(w.WriteNodesAsString(h.Title...), "")
|
||||||
w.WriteString(fmt.Sprintf("<a href=\"#%s\">%s</a>\n", h.ID(), title))
|
w.WriteString(fmt.Sprintf("<a href=\"#%s\">%s</a>\n", h.ID(), title))
|
||||||
if len(section.Children) != 0 {
|
if len(section.Children) != 0 {
|
||||||
w.WriteString("<ul>\n")
|
w.WriteString("<ul>\n")
|
||||||
|
@ -306,7 +305,7 @@ func (w *HTMLWriter) WriteRegularLink(l RegularLink) {
|
||||||
}
|
}
|
||||||
description := url
|
description := url
|
||||||
if l.Description != nil {
|
if l.Description != nil {
|
||||||
description = w.nodesAsString(l.Description...)
|
description = w.WriteNodesAsString(l.Description...)
|
||||||
}
|
}
|
||||||
switch l.Kind() {
|
switch l.Kind() {
|
||||||
case "image":
|
case "image":
|
||||||
|
@ -384,10 +383,10 @@ func (w *HTMLWriter) WriteHorizontalRule(h HorizontalRule) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *HTMLWriter) WriteNodeWithMeta(n NodeWithMeta) {
|
func (w *HTMLWriter) WriteNodeWithMeta(n NodeWithMeta) {
|
||||||
out := w.nodesAsString(n.Node)
|
out := w.WriteNodesAsString(n.Node)
|
||||||
if p, ok := n.Node.(Paragraph); ok {
|
if p, ok := n.Node.(Paragraph); ok {
|
||||||
if len(p.Children) == 1 && isImageOrVideoLink(p.Children[0]) {
|
if len(p.Children) == 1 && isImageOrVideoLink(p.Children[0]) {
|
||||||
out = w.nodesAsString(p.Children[0])
|
out = w.WriteNodesAsString(p.Children[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, attributes := range n.Meta.HTMLAttributes {
|
for _, attributes := range n.Meta.HTMLAttributes {
|
||||||
|
@ -399,7 +398,7 @@ func (w *HTMLWriter) WriteNodeWithMeta(n NodeWithMeta) {
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
caption += " "
|
caption += " "
|
||||||
}
|
}
|
||||||
caption += w.nodesAsString(ns...)
|
caption += w.WriteNodesAsString(ns...)
|
||||||
}
|
}
|
||||||
out = fmt.Sprintf("<figure>\n%s<figcaption>\n%s\n</figcaption>\n</figure>\n", out, caption)
|
out = fmt.Sprintf("<figure>\n%s<figcaption>\n%s\n</figcaption>\n</figure>\n", out, caption)
|
||||||
}
|
}
|
||||||
|
|
22
vendor/github.com/niklasfasching/go-org/org/inline.go
generated
vendored
22
vendor/github.com/niklasfasching/go-org/org/inline.go
generated
vendored
|
@ -147,8 +147,8 @@ func (d *Document) parseExplicitLineBreakOrLatexFragment(input string, start int
|
||||||
switch {
|
switch {
|
||||||
case start+2 >= len(input):
|
case start+2 >= len(input):
|
||||||
case input[start+1] == '\\' && start != 0 && input[start-1] != '\n':
|
case input[start+1] == '\\' && start != 0 && input[start-1] != '\n':
|
||||||
for i := start + 2; unicode.IsSpace(rune(input[i])); i++ {
|
for i := start + 2; i <= len(input)-1 && unicode.IsSpace(rune(input[i])); i++ {
|
||||||
if i >= len(input) || input[i] == '\n' {
|
if input[i] == '\n' {
|
||||||
return i + 1 - start, ExplicitLineBreak{}
|
return i + 1 - start, ExplicitLineBreak{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -346,12 +346,12 @@ func (l RegularLink) Kind() string {
|
||||||
return "regular"
|
return "regular"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n Text) String() string { return orgWriter.nodesAsString(n) }
|
func (n Text) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n LineBreak) String() string { return orgWriter.nodesAsString(n) }
|
func (n LineBreak) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n ExplicitLineBreak) String() string { return orgWriter.nodesAsString(n) }
|
func (n ExplicitLineBreak) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n StatisticToken) String() string { return orgWriter.nodesAsString(n) }
|
func (n StatisticToken) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n Emphasis) String() string { return orgWriter.nodesAsString(n) }
|
func (n Emphasis) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n LatexFragment) String() string { return orgWriter.nodesAsString(n) }
|
func (n LatexFragment) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n FootnoteLink) String() string { return orgWriter.nodesAsString(n) }
|
func (n FootnoteLink) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n RegularLink) String() string { return orgWriter.nodesAsString(n) }
|
func (n RegularLink) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n Timestamp) String() string { return orgWriter.nodesAsString(n) }
|
func (n Timestamp) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
|
|
10
vendor/github.com/niklasfasching/go-org/org/keyword.go
generated
vendored
10
vendor/github.com/niklasfasching/go-org/org/keyword.go
generated
vendored
|
@ -177,8 +177,8 @@ func (d *Document) loadSetupFile(k Keyword) (int, Node) {
|
||||||
return 1, k
|
return 1, k
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n Comment) String() string { return orgWriter.nodesAsString(n) }
|
func (n Comment) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n Keyword) String() string { return orgWriter.nodesAsString(n) }
|
func (n Keyword) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n NodeWithMeta) String() string { return orgWriter.nodesAsString(n) }
|
func (n NodeWithMeta) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n NodeWithName) String() string { return orgWriter.nodesAsString(n) }
|
func (n NodeWithName) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n Include) String() string { return orgWriter.nodesAsString(n) }
|
func (n Include) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
|
|
6
vendor/github.com/niklasfasching/go-org/org/list.go
generated
vendored
6
vendor/github.com/niklasfasching/go-org/org/list.go
generated
vendored
|
@ -109,6 +109,6 @@ func (d *Document) parseListItem(l List, i int, parentStop stopFn) (int, Node) {
|
||||||
return i - start, ListItem{bullet, status, nodes}
|
return i - start, ListItem{bullet, status, nodes}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n List) String() string { return orgWriter.nodesAsString(n) }
|
func (n List) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n ListItem) String() string { return orgWriter.nodesAsString(n) }
|
func (n ListItem) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n DescriptiveListItem) String() string { return orgWriter.nodesAsString(n) }
|
func (n DescriptiveListItem) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
|
|
71
vendor/github.com/niklasfasching/go-org/org/org_writer.go
generated
vendored
71
vendor/github.com/niklasfasching/go-org/org/org_writer.go
generated
vendored
|
@ -43,39 +43,33 @@ func (w *OrgWriter) WriterWithExtensions() Writer {
|
||||||
func (w *OrgWriter) Before(d *Document) {}
|
func (w *OrgWriter) Before(d *Document) {}
|
||||||
func (w *OrgWriter) After(d *Document) {}
|
func (w *OrgWriter) After(d *Document) {}
|
||||||
|
|
||||||
func (w *OrgWriter) emptyClone() *OrgWriter {
|
func (w *OrgWriter) WriteNodesAsString(nodes ...Node) string {
|
||||||
wcopy := *w
|
builder := w.Builder
|
||||||
wcopy.Builder = strings.Builder{}
|
w.Builder = strings.Builder{}
|
||||||
return &wcopy
|
WriteNodes(w, nodes...)
|
||||||
}
|
out := w.String()
|
||||||
|
w.Builder = builder
|
||||||
func (w *OrgWriter) nodesAsString(nodes ...Node) string {
|
return out
|
||||||
tmp := w.emptyClone()
|
|
||||||
WriteNodes(tmp, nodes...)
|
|
||||||
return tmp.String()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *OrgWriter) WriteHeadline(h Headline) {
|
func (w *OrgWriter) WriteHeadline(h Headline) {
|
||||||
tmp := w.emptyClone()
|
start := w.Len()
|
||||||
tmp.WriteString(strings.Repeat("*", h.Lvl))
|
w.WriteString(strings.Repeat("*", h.Lvl))
|
||||||
if h.Status != "" {
|
if h.Status != "" {
|
||||||
tmp.WriteString(" " + h.Status)
|
w.WriteString(" " + h.Status)
|
||||||
}
|
}
|
||||||
if h.Priority != "" {
|
if h.Priority != "" {
|
||||||
tmp.WriteString(" [#" + h.Priority + "]")
|
w.WriteString(" [#" + h.Priority + "]")
|
||||||
}
|
}
|
||||||
tmp.WriteString(" ")
|
w.WriteString(" ")
|
||||||
WriteNodes(tmp, h.Title...)
|
WriteNodes(w, h.Title...)
|
||||||
hString := tmp.String()
|
|
||||||
if len(h.Tags) != 0 {
|
if len(h.Tags) != 0 {
|
||||||
tString := ":" + strings.Join(h.Tags, ":") + ":"
|
tString := ":" + strings.Join(h.Tags, ":") + ":"
|
||||||
if n := w.TagsColumn - len(tString) - len(hString); n > 0 {
|
if n := w.TagsColumn - len(tString) - (w.Len() - start); n > 0 {
|
||||||
w.WriteString(hString + strings.Repeat(" ", n) + tString)
|
w.WriteString(strings.Repeat(" ", n) + tString)
|
||||||
} else {
|
} else {
|
||||||
w.WriteString(hString + " " + tString)
|
w.WriteString(" " + tString)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
w.WriteString(hString)
|
|
||||||
}
|
}
|
||||||
w.WriteString("\n")
|
w.WriteString("\n")
|
||||||
if len(h.Children) != 0 {
|
if len(h.Children) != 0 {
|
||||||
|
@ -123,7 +117,7 @@ func (w *OrgWriter) WritePropertyDrawer(d PropertyDrawer) {
|
||||||
|
|
||||||
func (w *OrgWriter) WriteFootnoteDefinition(f FootnoteDefinition) {
|
func (w *OrgWriter) WriteFootnoteDefinition(f FootnoteDefinition) {
|
||||||
w.WriteString(fmt.Sprintf("[fn:%s]", f.Name))
|
w.WriteString(fmt.Sprintf("[fn:%s]", f.Name))
|
||||||
content := w.nodesAsString(f.Children...)
|
content := w.WriteNodesAsString(f.Children...)
|
||||||
if content != "" && !unicode.IsSpace(rune(content[0])) {
|
if content != "" && !unicode.IsSpace(rune(content[0])) {
|
||||||
w.WriteString(" ")
|
w.WriteString(" ")
|
||||||
}
|
}
|
||||||
|
@ -131,7 +125,7 @@ func (w *OrgWriter) WriteFootnoteDefinition(f FootnoteDefinition) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *OrgWriter) WriteParagraph(p Paragraph) {
|
func (w *OrgWriter) WriteParagraph(p Paragraph) {
|
||||||
content := w.nodesAsString(p.Children...)
|
content := w.WriteNodesAsString(p.Children...)
|
||||||
if len(content) > 0 && content[0] != '\n' {
|
if len(content) > 0 && content[0] != '\n' {
|
||||||
w.WriteString(w.indent)
|
w.WriteString(w.indent)
|
||||||
}
|
}
|
||||||
|
@ -141,7 +135,7 @@ func (w *OrgWriter) WriteParagraph(p Paragraph) {
|
||||||
func (w *OrgWriter) WriteExample(e Example) {
|
func (w *OrgWriter) WriteExample(e Example) {
|
||||||
for _, n := range e.Children {
|
for _, n := range e.Children {
|
||||||
w.WriteString(w.indent + ":")
|
w.WriteString(w.indent + ":")
|
||||||
if content := w.nodesAsString(n); content != "" {
|
if content := w.WriteNodesAsString(n); content != "" {
|
||||||
w.WriteString(" " + content)
|
w.WriteString(" " + content)
|
||||||
}
|
}
|
||||||
w.WriteString("\n")
|
w.WriteString("\n")
|
||||||
|
@ -185,10 +179,11 @@ func (w *OrgWriter) WriteComment(c Comment) {
|
||||||
func (w *OrgWriter) WriteList(l List) { WriteNodes(w, l.Items...) }
|
func (w *OrgWriter) WriteList(l List) { WriteNodes(w, l.Items...) }
|
||||||
|
|
||||||
func (w *OrgWriter) WriteListItem(li ListItem) {
|
func (w *OrgWriter) WriteListItem(li ListItem) {
|
||||||
liWriter := w.emptyClone()
|
originalBuilder, originalIndent := w.Builder, w.indent
|
||||||
liWriter.indent = w.indent + strings.Repeat(" ", len(li.Bullet)+1)
|
w.Builder, w.indent = strings.Builder{}, w.indent+strings.Repeat(" ", len(li.Bullet)+1)
|
||||||
WriteNodes(liWriter, li.Children...)
|
WriteNodes(w, li.Children...)
|
||||||
content := strings.TrimPrefix(liWriter.String(), liWriter.indent)
|
content := strings.TrimPrefix(w.String(), w.indent)
|
||||||
|
w.Builder, w.indent = originalBuilder, originalIndent
|
||||||
w.WriteString(w.indent + li.Bullet)
|
w.WriteString(w.indent + li.Bullet)
|
||||||
if li.Status != "" {
|
if li.Status != "" {
|
||||||
w.WriteString(fmt.Sprintf(" [%s]", li.Status))
|
w.WriteString(fmt.Sprintf(" [%s]", li.Status))
|
||||||
|
@ -207,14 +202,15 @@ func (w *OrgWriter) WriteDescriptiveListItem(di DescriptiveListItem) {
|
||||||
}
|
}
|
||||||
indent := w.indent + strings.Repeat(" ", len(di.Bullet)+1)
|
indent := w.indent + strings.Repeat(" ", len(di.Bullet)+1)
|
||||||
if len(di.Term) != 0 {
|
if len(di.Term) != 0 {
|
||||||
term := w.nodesAsString(di.Term...)
|
term := w.WriteNodesAsString(di.Term...)
|
||||||
w.WriteString(" " + term + " ::")
|
w.WriteString(" " + term + " ::")
|
||||||
indent = indent + strings.Repeat(" ", len(term)+4)
|
indent = indent + strings.Repeat(" ", len(term)+4)
|
||||||
}
|
}
|
||||||
diWriter := w.emptyClone()
|
originalBuilder, originalIndent := w.Builder, w.indent
|
||||||
diWriter.indent = indent
|
w.Builder, w.indent = strings.Builder{}, indent
|
||||||
WriteNodes(diWriter, di.Details...)
|
WriteNodes(w, di.Details...)
|
||||||
details := strings.TrimPrefix(diWriter.String(), diWriter.indent)
|
details := strings.TrimPrefix(w.String(), w.indent)
|
||||||
|
w.Builder, w.indent = originalBuilder, originalIndent
|
||||||
if len(details) > 0 && details[0] == '\n' {
|
if len(details) > 0 && details[0] == '\n' {
|
||||||
w.WriteString(details)
|
w.WriteString(details)
|
||||||
} else {
|
} else {
|
||||||
|
@ -239,7 +235,7 @@ func (w *OrgWriter) WriteTable(t Table) {
|
||||||
w.WriteString(`|`)
|
w.WriteString(`|`)
|
||||||
for _, column := range row.Columns {
|
for _, column := range row.Columns {
|
||||||
w.WriteString(` `)
|
w.WriteString(` `)
|
||||||
content := w.nodesAsString(column.Children...)
|
content := w.WriteNodesAsString(column.Children...)
|
||||||
if content == "" {
|
if content == "" {
|
||||||
content = " "
|
content = " "
|
||||||
}
|
}
|
||||||
|
@ -326,9 +322,6 @@ func (w *OrgWriter) WriteRegularLink(l RegularLink) {
|
||||||
} else if l.Description == nil {
|
} else if l.Description == nil {
|
||||||
w.WriteString(fmt.Sprintf("[[%s]]", l.URL))
|
w.WriteString(fmt.Sprintf("[[%s]]", l.URL))
|
||||||
} else {
|
} else {
|
||||||
descriptionWriter := w.emptyClone()
|
w.WriteString(fmt.Sprintf("[[%s][%s]]", l.URL, w.WriteNodesAsString(l.Description...)))
|
||||||
WriteNodes(descriptionWriter, l.Description...)
|
|
||||||
description := descriptionWriter.String()
|
|
||||||
w.WriteString(fmt.Sprintf("[[%s][%s]]", l.URL, description))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
4
vendor/github.com/niklasfasching/go-org/org/paragraph.go
generated
vendored
4
vendor/github.com/niklasfasching/go-org/org/paragraph.go
generated
vendored
|
@ -42,5 +42,5 @@ func (d *Document) parseHorizontalRule(i int, parentStop stopFn) (int, Node) {
|
||||||
return 1, HorizontalRule{}
|
return 1, HorizontalRule{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n Paragraph) String() string { return orgWriter.nodesAsString(n) }
|
func (n Paragraph) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
func (n HorizontalRule) String() string { return orgWriter.nodesAsString(n) }
|
func (n HorizontalRule) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
|
|
2
vendor/github.com/niklasfasching/go-org/org/table.go
generated
vendored
2
vendor/github.com/niklasfasching/go-org/org/table.go
generated
vendored
|
@ -127,4 +127,4 @@ func isSpecialRow(rawColumns []string) bool {
|
||||||
return isAlignRow
|
return isAlignRow
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n Table) String() string { return orgWriter.nodesAsString(n) }
|
func (n Table) String() string { return orgWriter.WriteNodesAsString(n) }
|
||||||
|
|
1
vendor/github.com/niklasfasching/go-org/org/writer.go
generated
vendored
1
vendor/github.com/niklasfasching/go-org/org/writer.go
generated
vendored
|
@ -9,6 +9,7 @@ type Writer interface {
|
||||||
String() string // String is called at the very end to retrieve the final output.
|
String() string // String is called at the very end to retrieve the final output.
|
||||||
|
|
||||||
WriterWithExtensions() Writer
|
WriterWithExtensions() Writer
|
||||||
|
WriteNodesAsString(...Node) string
|
||||||
|
|
||||||
WriteKeyword(Keyword)
|
WriteKeyword(Keyword)
|
||||||
WriteInclude(Include)
|
WriteInclude(Include)
|
||||||
|
|
2
vendor/golang.org/x/net/idna/tables11.0.0.go
generated
vendored
2
vendor/golang.org/x/net/idna/tables11.0.0.go
generated
vendored
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
// +build go1.13
|
// +build go1.13,!go1.14
|
||||||
|
|
||||||
package idna
|
package idna
|
||||||
|
|
||||||
|
|
4733
vendor/golang.org/x/net/idna/tables12.00.go
generated
vendored
Normal file
4733
vendor/golang.org/x/net/idna/tables12.00.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
|
@ -330,7 +330,7 @@ github.com/mschoch/smat
|
||||||
github.com/msteinert/pam
|
github.com/msteinert/pam
|
||||||
# github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5
|
# github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5
|
||||||
github.com/nfnt/resize
|
github.com/nfnt/resize
|
||||||
# github.com/niklasfasching/go-org v0.1.7
|
# github.com/niklasfasching/go-org v0.1.8
|
||||||
github.com/niklasfasching/go-org/org
|
github.com/niklasfasching/go-org/org
|
||||||
# github.com/oliamb/cutter v0.2.2
|
# github.com/oliamb/cutter v0.2.2
|
||||||
github.com/oliamb/cutter
|
github.com/oliamb/cutter
|
||||||
|
@ -464,7 +464,7 @@ golang.org/x/crypto/scrypt
|
||||||
golang.org/x/crypto/ssh
|
golang.org/x/crypto/ssh
|
||||||
golang.org/x/crypto/ssh/agent
|
golang.org/x/crypto/ssh/agent
|
||||||
golang.org/x/crypto/ssh/knownhosts
|
golang.org/x/crypto/ssh/knownhosts
|
||||||
# golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271
|
# golang.org/x/net v0.0.0-20191101175033-0deb6923b6d9
|
||||||
golang.org/x/net/context
|
golang.org/x/net/context
|
||||||
golang.org/x/net/context/ctxhttp
|
golang.org/x/net/context/ctxhttp
|
||||||
golang.org/x/net/html
|
golang.org/x/net/html
|
||||||
|
|
Reference in a new issue