diff options
Diffstat (limited to 'vendor/github.com/yuin/goldmark/ast/block.go')
| -rw-r--r-- | vendor/github.com/yuin/goldmark/ast/block.go | 49 |
1 files changed, 39 insertions, 10 deletions
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{ |
