summaryrefslogtreecommitdiff
path: root/vendor/github.com/yuin/goldmark/ast
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2024-10-21 11:37:00 +0200
committerLibravatar GitHub <noreply@github.com>2024-10-21 11:37:00 +0200
commitea1bf5f8a37992aa547573a42332235dc7142399 (patch)
tree9f89eabc416ec6339f02d4092182e055a8227f7a /vendor/github.com/yuin/goldmark/ast
parent[bugfix] Fix filter title unique constraint (#3458) (diff)
downloadgotosocial-ea1bf5f8a37992aa547573a42332235dc7142399.tar.xz
[chore]: Bump github.com/yuin/goldmark from 1.7.6 to 1.7.8 (#3470)
Bumps [github.com/yuin/goldmark](https://github.com/yuin/goldmark) from 1.7.6 to 1.7.8. - [Release notes](https://github.com/yuin/goldmark/releases) - [Commits](https://github.com/yuin/goldmark/compare/v1.7.6...v1.7.8) --- updated-dependencies: - dependency-name: github.com/yuin/goldmark dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/yuin/goldmark/ast')
-rw-r--r--vendor/github.com/yuin/goldmark/ast/ast.go15
-rw-r--r--vendor/github.com/yuin/goldmark/ast/block.go49
-rw-r--r--vendor/github.com/yuin/goldmark/ast/inline.go32
3 files changed, 81 insertions, 15 deletions
diff --git a/vendor/github.com/yuin/goldmark/ast/ast.go b/vendor/github.com/yuin/goldmark/ast/ast.go
index 67bb0da56..36ba606f7 100644
--- a/vendor/github.com/yuin/goldmark/ast/ast.go
+++ b/vendor/github.com/yuin/goldmark/ast/ast.go
@@ -123,6 +123,12 @@ type Node interface {
Dump(source []byte, level int)
// Text returns text values of this node.
+ // This method is valid only for some inline nodes.
+ // If this node is a block node, Text returns a text value as reasonable as possible.
+ // Notice that there are no 'correct' text values for the block nodes.
+ // Result for the block nodes may be different from your expectation.
+ //
+ // Deprecated: Use other properties of the node to get the text value(i.e. Pragraph.Lines, Text.Value).
Text(source []byte) []byte
// HasBlankPreviousLines returns true if the row before this node is blank,
@@ -374,11 +380,18 @@ func (n *BaseNode) OwnerDocument() *Document {
return nil
}
-// Text implements Node.Text .
+// Text implements Node.Text .
+//
+// Deprecated: Use other properties of the node to get the text value(i.e. Pragraph.Lines, Text.Value).
func (n *BaseNode) Text(source []byte) []byte {
var buf bytes.Buffer
for c := n.firstChild; c != nil; c = c.NextSibling() {
buf.Write(c.Text(source))
+ if sb, ok := c.(interface {
+ SoftLineBreak() bool
+ }); ok && sb.SoftLineBreak() {
+ buf.WriteByte('\n')
+ }
}
return buf.Bytes()
}
diff --git a/vendor/github.com/yuin/goldmark/ast/block.go b/vendor/github.com/yuin/goldmark/ast/block.go
index 04d0d5443..eae7acdca 100644
--- a/vendor/github.com/yuin/goldmark/ast/block.go
+++ b/vendor/github.com/yuin/goldmark/ast/block.go
@@ -1,7 +1,6 @@
package ast
import (
- "bytes"
"fmt"
"strings"
@@ -48,15 +47,6 @@ func (b *BaseBlock) SetLines(v *textm.Segments) {
b.lines = v
}
-// Text implements Node.Text.
-func (b *BaseBlock) Text(source []byte) []byte {
- var buf bytes.Buffer
- for _, line := range b.Lines().Sliced(0, b.Lines().Len()) {
- buf.Write(line.Value(source))
- }
- return buf.Bytes()
-}
-
// A Document struct is a root node of Markdown text.
type Document struct {
BaseBlock
@@ -140,6 +130,13 @@ func (n *TextBlock) Kind() NodeKind {
return KindTextBlock
}
+// Text implements Node.Text.
+//
+// Deprecated: Use other properties of the node to get the text value(i.e. TextBlock.Lines).
+func (n *TextBlock) Text(source []byte) []byte {
+ return n.Lines().Value(source)
+}
+
// NewTextBlock returns a new TextBlock node.
func NewTextBlock() *TextBlock {
return &TextBlock{
@@ -165,6 +162,13 @@ func (n *Paragraph) Kind() NodeKind {
return KindParagraph
}
+// Text implements Node.Text.
+//
+// Deprecated: Use other properties of the node to get the text value(i.e. Paragraph.Lines).
+func (n *Paragraph) Text(source []byte) []byte {
+ return n.Lines().Value(source)
+}
+
// NewParagraph returns a new Paragraph node.
func NewParagraph() *Paragraph {
return &Paragraph{
@@ -259,6 +263,13 @@ func (n *CodeBlock) Kind() NodeKind {
return KindCodeBlock
}
+// Text implements Node.Text.
+//
+// Deprecated: Use other properties of the node to get the text value(i.e. CodeBlock.Lines).
+func (n *CodeBlock) Text(source []byte) []byte {
+ return n.Lines().Value(source)
+}
+
// NewCodeBlock returns a new CodeBlock node.
func NewCodeBlock() *CodeBlock {
return &CodeBlock{
@@ -314,6 +325,13 @@ func (n *FencedCodeBlock) Kind() NodeKind {
return KindFencedCodeBlock
}
+// Text implements Node.Text.
+//
+// Deprecated: Use other properties of the node to get the text value(i.e. FencedCodeBlock.Lines).
+func (n *FencedCodeBlock) Text(source []byte) []byte {
+ return n.Lines().Value(source)
+}
+
// NewFencedCodeBlock return a new FencedCodeBlock node.
func NewFencedCodeBlock(info *Text) *FencedCodeBlock {
return &FencedCodeBlock{
@@ -508,6 +526,17 @@ func (n *HTMLBlock) Kind() NodeKind {
return KindHTMLBlock
}
+// Text implements Node.Text.
+//
+// Deprecated: Use other properties of the node to get the text value(i.e. HTMLBlock.Lines).
+func (n *HTMLBlock) Text(source []byte) []byte {
+ ret := n.Lines().Value(source)
+ if n.HasClosure() {
+ ret = append(ret, n.ClosureLine.Value(source)...)
+ }
+ return ret
+}
+
// NewHTMLBlock returns a new HTMLBlock node.
func NewHTMLBlock(typ HTMLBlockType) *HTMLBlock {
return &HTMLBlock{
diff --git a/vendor/github.com/yuin/goldmark/ast/inline.go b/vendor/github.com/yuin/goldmark/ast/inline.go
index 7e4c51f23..613eb1edc 100644
--- a/vendor/github.com/yuin/goldmark/ast/inline.go
+++ b/vendor/github.com/yuin/goldmark/ast/inline.go
@@ -143,17 +143,25 @@ func (n *Text) Merge(node Node, source []byte) bool {
}
// Text implements Node.Text.
+//
+// Deprecated: Use other properties of the node to get the text value(i.e. Text.Value).
func (n *Text) Text(source []byte) []byte {
return n.Segment.Value(source)
}
+// Value returns a value of this node.
+// SoftLineBreaks are not included in the returned value.
+func (n *Text) Value(source []byte) []byte {
+ return n.Segment.Value(source)
+}
+
// Dump implements Node.Dump.
func (n *Text) Dump(source []byte, level int) {
fs := textFlagsString(n.flags)
if len(fs) != 0 {
fs = "(" + fs + ")"
}
- fmt.Printf("%sText%s: \"%s\"\n", strings.Repeat(" ", level), fs, strings.TrimRight(string(n.Text(source)), "\n"))
+ fmt.Printf("%sText%s: \"%s\"\n", strings.Repeat(" ", level), fs, strings.TrimRight(string(n.Value(source)), "\n"))
}
// KindText is a NodeKind of the Text node.
@@ -258,6 +266,8 @@ func (n *String) SetCode(v bool) {
}
// Text implements Node.Text.
+//
+// Deprecated: Use other properties of the node to get the text value(i.e. String.Value).
func (n *String) Text(source []byte) []byte {
return n.Value
}
@@ -492,15 +502,22 @@ func (n *AutoLink) URL(source []byte) []byte {
ret := make([]byte, 0, len(n.Protocol)+s.Len()+3)
ret = append(ret, n.Protocol...)
ret = append(ret, ':', '/', '/')
- ret = append(ret, n.value.Text(source)...)
+ ret = append(ret, n.value.Value(source)...)
return ret
}
- return n.value.Text(source)
+ return n.value.Value(source)
}
// Label returns a label of this node.
func (n *AutoLink) Label(source []byte) []byte {
- return n.value.Text(source)
+ return n.value.Value(source)
+}
+
+// Text implements Node.Text.
+//
+// Deprecated: Use other properties of the node to get the text value(i.e. AutoLink.Label).
+func (n *AutoLink) Text(source []byte) []byte {
+ return n.value.Value(source)
}
// NewAutoLink returns a new AutoLink node.
@@ -541,6 +558,13 @@ func (n *RawHTML) Kind() NodeKind {
return KindRawHTML
}
+// Text implements Node.Text.
+//
+// Deprecated: Use other properties of the node to get the text value(i.e. RawHTML.Segments).
+func (n *RawHTML) Text(source []byte) []byte {
+ return n.Segments.Value(source)
+}
+
// NewRawHTML returns a new RawHTML node.
func NewRawHTML() *RawHTML {
return &RawHTML{