summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-03-20 11:23:55 +0000
committerGitHub <noreply@github.com>2021-03-20 12:23:55 +0100
commit9ed9ed9ae019918544c0656199235aa23e013f95 (patch)
treeb1843fada5111969c3e239b3f2f12a0fbd353b82 /vendor
parentd05539eb3e49542ba99af8f4add677f410246aa7 (diff)
downloadgitea-9ed9ed9ae019918544c0656199235aa23e013f95.tar.gz
gitea-9ed9ed9ae019918544c0656199235aa23e013f95.zip
Update to goldmark 1.3.3 (#15059)
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/yuin/goldmark/extension/table.go41
-rw-r--r--vendor/modules.txt2
2 files changed, 28 insertions, 15 deletions
diff --git a/vendor/github.com/yuin/goldmark/extension/table.go b/vendor/github.com/yuin/goldmark/extension/table.go
index c40bdefc5c..c637b99f04 100644
--- a/vendor/github.com/yuin/goldmark/extension/table.go
+++ b/vendor/github.com/yuin/goldmark/extension/table.go
@@ -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
}
}
}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index a9c6f6c1c3..7069aaffef 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -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