]> source.dussan.org Git - gitea.git/commitdiff
Update to goldmark 1.3.3 (#15059)
authorzeripath <art27@cantab.net>
Sat, 20 Mar 2021 11:23:55 +0000 (11:23 +0000)
committerGitHub <noreply@github.com>
Sat, 20 Mar 2021 11:23:55 +0000 (12:23 +0100)
Signed-off-by: Andrew Thornton <art27@cantab.net>
go.mod
go.sum
vendor/github.com/yuin/goldmark/extension/table.go
vendor/modules.txt

diff --git a/go.mod b/go.mod
index a4a5706ccfca2334bb8bc6c4aae28f891b54ef50..165c8f6933f7f4bb771b65538eb0fcb3919d71b9 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -128,7 +128,7 @@ require (
        github.com/xanzy/go-gitlab v0.44.0
        github.com/xanzy/ssh-agent v0.3.0 // indirect
        github.com/yohcop/openid-go v1.0.0
-       github.com/yuin/goldmark v1.3.2
+       github.com/yuin/goldmark v1.3.3
        github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691
        github.com/yuin/goldmark-meta v1.0.0
        go.jolheiser.com/hcaptcha v0.0.4
diff --git a/go.sum b/go.sum
index 860d807f963d73454e9b944cf4065fede53ad590..09dc22e8f00cf9a518c53de782e0d3e63a5ae008 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -1145,8 +1145,8 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
 github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
-github.com/yuin/goldmark v1.3.2 h1:YjHC5TgyMmHpicTgEqDN0Q96Xo8K6tLXPnmNOHXCgs0=
-github.com/yuin/goldmark v1.3.2/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
+github.com/yuin/goldmark v1.3.3 h1:37BdQwPx8VOSic8eDSWee6QL9mRpZRm9VJp/QugNrW0=
+github.com/yuin/goldmark v1.3.3/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
 github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691 h1:VWSxtAiQNh3zgHJpdpkpVYjTPqRE3P6UZCOPa1nRDio=
 github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691/go.mod h1:YLF3kDffRfUH/bTxOxHhV6lxwIB3Vfj91rEwNMS9MXo=
 github.com/yuin/goldmark-meta v1.0.0 h1:ScsatUIT2gFS6azqzLGUjgOnELsBOxMXerM3ogdJhAM=
index c40bdefc5c81338d36f89f4072e6886f15e3857c..c637b99f044dfb595fcba4db39eb24a01f796a82 100644 (file)
@@ -18,8 +18,9 @@ import (
 var escapedPipeCellListKey = parser.NewContextKey()
 
 type escapedPipeCell struct {
-       Cell *ast.TableCell
-       Pos  []int
+       Cell        *ast.TableCell
+       Pos         []int
+       Transformed bool
 }
 
 // TableCellAlignMethod indicates how are table cells aligned in HTML format.indicates how are table cells aligned in HTML format.
@@ -216,7 +217,7 @@ func (b *tableParagraphTransformer) parseRow(segment text.Segment, alignments []
                                        break
                                } else if hasBacktick {
                                        if escapedCell == nil {
-                                               escapedCell = &escapedPipeCell{node, []int{}}
+                                               escapedCell = &escapedPipeCell{node, []int{}, false}
                                                escapedList := pc.ComputeIfAbsent(escapedPipeCellListKey,
                                                        func() interface{} {
                                                                return []*escapedPipeCell{}
@@ -288,22 +289,34 @@ func (a *tableASTTransformer) Transform(node *gast.Document, reader text.Reader,
        }
        pc.Set(escapedPipeCellListKey, nil)
        for _, v := range lst.([]*escapedPipeCell) {
+               if v.Transformed {
+                       continue
+               }
                _ = gast.Walk(v.Cell, func(n gast.Node, entering bool) (gast.WalkStatus, error) {
-                       if n.Kind() != gast.KindCodeSpan {
+                       if !entering || n.Kind() != gast.KindCodeSpan {
                                return gast.WalkContinue, nil
                        }
-                       c := n.FirstChild()
-                       for c != nil {
+
+                       for c := n.FirstChild(); c != nil; {
                                next := c.NextSibling()
-                               if c.Kind() == gast.KindText {
-                                       t := c.(*gast.Text)
+                               if c.Kind() != gast.KindText {
+                                       c = next
+                                       continue
+                               }
+                               parent := c.Parent()
+                               ts := &c.(*gast.Text).Segment
+                               n := c
+                               for _, v := range lst.([]*escapedPipeCell) {
                                        for _, pos := range v.Pos {
-                                               if t.Segment.Start <= pos && t.Segment.Stop > pos {
-                                                       n1 := gast.NewRawTextSegment(t.Segment.WithStop(pos))
-                                                       n2 := gast.NewRawTextSegment(t.Segment.WithStart(pos + 1))
-                                                       n.InsertAfter(n, c, n1)
-                                                       n.InsertAfter(n, n1, n2)
-                                                       n.RemoveChild(n, c)
+                                               if ts.Start <= pos && pos < ts.Stop {
+                                                       segment := n.(*gast.Text).Segment
+                                                       n1 := gast.NewRawTextSegment(segment.WithStop(pos))
+                                                       n2 := gast.NewRawTextSegment(segment.WithStart(pos + 1))
+                                                       parent.InsertAfter(parent, n, n1)
+                                                       parent.InsertAfter(parent, n1, n2)
+                                                       parent.RemoveChild(parent, n)
+                                                       n = n2
+                                                       v.Transformed = true
                                                }
                                        }
                                }
index a9c6f6c1c33a24c56deaffe839d04182c1acb0ce..7069aaffef27c43fd8d7167a214406c4cace8a8d 100644 (file)
@@ -798,7 +798,7 @@ github.com/xi2/xz
 # github.com/yohcop/openid-go v1.0.0
 ## explicit
 github.com/yohcop/openid-go
-# github.com/yuin/goldmark v1.3.2
+# github.com/yuin/goldmark v1.3.3
 ## explicit
 github.com/yuin/goldmark
 github.com/yuin/goldmark/ast