summaryrefslogtreecommitdiff
path: root/vendor/github.com/yuin/goldmark/extension/ast
diff options
context:
space:
mode:
authorLibravatar Autumn! <86073772+autumnull@users.noreply.github.com>2022-12-16 11:20:22 +0000
committerLibravatar GitHub <noreply@github.com>2022-12-16 12:20:22 +0100
commiteb08529f35ce33ed98c34fb48013f0f4a5fc9635 (patch)
tree394fd774a943f5c33ce793c67b5865f2570b46c5 /vendor/github.com/yuin/goldmark/extension/ast
parent[bugfix] use match-sorter for filtering domain blocks (#1270) (diff)
downloadgotosocial-eb08529f35ce33ed98c34fb48013f0f4a5fc9635.tar.xz
[chore/bugfix] Switch markdown from blackfriday to goldmark (#1267)
Co-authored-by: Autumn! <autumnull@posteo.net>
Diffstat (limited to 'vendor/github.com/yuin/goldmark/extension/ast')
-rw-r--r--vendor/github.com/yuin/goldmark/extension/ast/definition_list.go83
-rw-r--r--vendor/github.com/yuin/goldmark/extension/ast/footnote.go138
-rw-r--r--vendor/github.com/yuin/goldmark/extension/ast/strikethrough.go29
-rw-r--r--vendor/github.com/yuin/goldmark/extension/ast/table.go157
-rw-r--r--vendor/github.com/yuin/goldmark/extension/ast/tasklist.go35
5 files changed, 442 insertions, 0 deletions
diff --git a/vendor/github.com/yuin/goldmark/extension/ast/definition_list.go b/vendor/github.com/yuin/goldmark/extension/ast/definition_list.go
new file mode 100644
index 000000000..1beffb3aa
--- /dev/null
+++ b/vendor/github.com/yuin/goldmark/extension/ast/definition_list.go
@@ -0,0 +1,83 @@
+package ast
+
+import (
+ gast "github.com/yuin/goldmark/ast"
+)
+
+// A DefinitionList struct represents a definition list of Markdown
+// (PHPMarkdownExtra) text.
+type DefinitionList struct {
+ gast.BaseBlock
+ Offset int
+ TemporaryParagraph *gast.Paragraph
+}
+
+// Dump implements Node.Dump.
+func (n *DefinitionList) Dump(source []byte, level int) {
+ gast.DumpHelper(n, source, level, nil, nil)
+}
+
+// KindDefinitionList is a NodeKind of the DefinitionList node.
+var KindDefinitionList = gast.NewNodeKind("DefinitionList")
+
+// Kind implements Node.Kind.
+func (n *DefinitionList) Kind() gast.NodeKind {
+ return KindDefinitionList
+}
+
+// NewDefinitionList returns a new DefinitionList node.
+func NewDefinitionList(offset int, para *gast.Paragraph) *DefinitionList {
+ return &DefinitionList{
+ Offset: offset,
+ TemporaryParagraph: para,
+ }
+}
+
+// A DefinitionTerm struct represents a definition list term of Markdown
+// (PHPMarkdownExtra) text.
+type DefinitionTerm struct {
+ gast.BaseBlock
+}
+
+// Dump implements Node.Dump.
+func (n *DefinitionTerm) Dump(source []byte, level int) {
+ gast.DumpHelper(n, source, level, nil, nil)
+}
+
+// KindDefinitionTerm is a NodeKind of the DefinitionTerm node.
+var KindDefinitionTerm = gast.NewNodeKind("DefinitionTerm")
+
+// Kind implements Node.Kind.
+func (n *DefinitionTerm) Kind() gast.NodeKind {
+ return KindDefinitionTerm
+}
+
+// NewDefinitionTerm returns a new DefinitionTerm node.
+func NewDefinitionTerm() *DefinitionTerm {
+ return &DefinitionTerm{}
+}
+
+// A DefinitionDescription struct represents a definition list description of Markdown
+// (PHPMarkdownExtra) text.
+type DefinitionDescription struct {
+ gast.BaseBlock
+ IsTight bool
+}
+
+// Dump implements Node.Dump.
+func (n *DefinitionDescription) Dump(source []byte, level int) {
+ gast.DumpHelper(n, source, level, nil, nil)
+}
+
+// KindDefinitionDescription is a NodeKind of the DefinitionDescription node.
+var KindDefinitionDescription = gast.NewNodeKind("DefinitionDescription")
+
+// Kind implements Node.Kind.
+func (n *DefinitionDescription) Kind() gast.NodeKind {
+ return KindDefinitionDescription
+}
+
+// NewDefinitionDescription returns a new DefinitionDescription node.
+func NewDefinitionDescription() *DefinitionDescription {
+ return &DefinitionDescription{}
+}
diff --git a/vendor/github.com/yuin/goldmark/extension/ast/footnote.go b/vendor/github.com/yuin/goldmark/extension/ast/footnote.go
new file mode 100644
index 000000000..97fea4403
--- /dev/null
+++ b/vendor/github.com/yuin/goldmark/extension/ast/footnote.go
@@ -0,0 +1,138 @@
+package ast
+
+import (
+ "fmt"
+
+ gast "github.com/yuin/goldmark/ast"
+)
+
+// A FootnoteLink struct represents a link to a footnote of Markdown
+// (PHP Markdown Extra) text.
+type FootnoteLink struct {
+ gast.BaseInline
+ Index int
+ RefCount int
+ RefIndex int
+}
+
+// Dump implements Node.Dump.
+func (n *FootnoteLink) Dump(source []byte, level int) {
+ m := map[string]string{}
+ m["Index"] = fmt.Sprintf("%v", n.Index)
+ m["RefCount"] = fmt.Sprintf("%v", n.RefCount)
+ m["RefIndex"] = fmt.Sprintf("%v", n.RefIndex)
+ gast.DumpHelper(n, source, level, m, nil)
+}
+
+// KindFootnoteLink is a NodeKind of the FootnoteLink node.
+var KindFootnoteLink = gast.NewNodeKind("FootnoteLink")
+
+// Kind implements Node.Kind.
+func (n *FootnoteLink) Kind() gast.NodeKind {
+ return KindFootnoteLink
+}
+
+// NewFootnoteLink returns a new FootnoteLink node.
+func NewFootnoteLink(index int) *FootnoteLink {
+ return &FootnoteLink{
+ Index: index,
+ RefCount: 0,
+ RefIndex: 0,
+ }
+}
+
+// A FootnoteBacklink struct represents a link to a footnote of Markdown
+// (PHP Markdown Extra) text.
+type FootnoteBacklink struct {
+ gast.BaseInline
+ Index int
+ RefCount int
+ RefIndex int
+}
+
+// Dump implements Node.Dump.
+func (n *FootnoteBacklink) Dump(source []byte, level int) {
+ m := map[string]string{}
+ m["Index"] = fmt.Sprintf("%v", n.Index)
+ m["RefCount"] = fmt.Sprintf("%v", n.RefCount)
+ m["RefIndex"] = fmt.Sprintf("%v", n.RefIndex)
+ gast.DumpHelper(n, source, level, m, nil)
+}
+
+// KindFootnoteBacklink is a NodeKind of the FootnoteBacklink node.
+var KindFootnoteBacklink = gast.NewNodeKind("FootnoteBacklink")
+
+// Kind implements Node.Kind.
+func (n *FootnoteBacklink) Kind() gast.NodeKind {
+ return KindFootnoteBacklink
+}
+
+// NewFootnoteBacklink returns a new FootnoteBacklink node.
+func NewFootnoteBacklink(index int) *FootnoteBacklink {
+ return &FootnoteBacklink{
+ Index: index,
+ RefCount: 0,
+ RefIndex: 0,
+ }
+}
+
+// A Footnote struct represents a footnote of Markdown
+// (PHP Markdown Extra) text.
+type Footnote struct {
+ gast.BaseBlock
+ Ref []byte
+ Index int
+}
+
+// Dump implements Node.Dump.
+func (n *Footnote) Dump(source []byte, level int) {
+ m := map[string]string{}
+ m["Index"] = fmt.Sprintf("%v", n.Index)
+ m["Ref"] = fmt.Sprintf("%s", n.Ref)
+ gast.DumpHelper(n, source, level, m, nil)
+}
+
+// KindFootnote is a NodeKind of the Footnote node.
+var KindFootnote = gast.NewNodeKind("Footnote")
+
+// Kind implements Node.Kind.
+func (n *Footnote) Kind() gast.NodeKind {
+ return KindFootnote
+}
+
+// NewFootnote returns a new Footnote node.
+func NewFootnote(ref []byte) *Footnote {
+ return &Footnote{
+ Ref: ref,
+ Index: -1,
+ }
+}
+
+// A FootnoteList struct represents footnotes of Markdown
+// (PHP Markdown Extra) text.
+type FootnoteList struct {
+ gast.BaseBlock
+ Count int
+}
+
+// Dump implements Node.Dump.
+func (n *FootnoteList) Dump(source []byte, level int) {
+ m := map[string]string{}
+ m["Count"] = fmt.Sprintf("%v", n.Count)
+ gast.DumpHelper(n, source, level, m, nil)
+}
+
+// KindFootnoteList is a NodeKind of the FootnoteList node.
+var KindFootnoteList = gast.NewNodeKind("FootnoteList")
+
+// Kind implements Node.Kind.
+func (n *FootnoteList) Kind() gast.NodeKind {
+ return KindFootnoteList
+}
+
+// NewFootnoteList returns a new FootnoteList node.
+func NewFootnoteList() *FootnoteList {
+ return &FootnoteList{
+ Count: 0,
+ }
+}
diff --git a/vendor/github.com/yuin/goldmark/extension/ast/strikethrough.go b/vendor/github.com/yuin/goldmark/extension/ast/strikethrough.go
new file mode 100644
index 000000000..a9216b72e
--- /dev/null
+++ b/vendor/github.com/yuin/goldmark/extension/ast/strikethrough.go
@@ -0,0 +1,29 @@
+// Package ast defines AST nodes that represents extension's elements
+package ast
+
+import (
+ gast "github.com/yuin/goldmark/ast"
+)
+
+// A Strikethrough struct represents a strikethrough of GFM text.
+type Strikethrough struct {
+ gast.BaseInline
+}
+
+// Dump implements Node.Dump.
+func (n *Strikethrough) Dump(source []byte, level int) {
+ gast.DumpHelper(n, source, level, nil, nil)
+}
+
+// KindStrikethrough is a NodeKind of the Strikethrough node.
+var KindStrikethrough = gast.NewNodeKind("Strikethrough")
+
+// Kind implements Node.Kind.
+func (n *Strikethrough) Kind() gast.NodeKind {
+ return KindStrikethrough
+}
+
+// NewStrikethrough returns a new Strikethrough node.
+func NewStrikethrough() *Strikethrough {
+ return &Strikethrough{}
+}
diff --git a/vendor/github.com/yuin/goldmark/extension/ast/table.go b/vendor/github.com/yuin/goldmark/extension/ast/table.go
new file mode 100644
index 000000000..e9eff3ceb
--- /dev/null
+++ b/vendor/github.com/yuin/goldmark/extension/ast/table.go
@@ -0,0 +1,157 @@
+package ast
+
+import (
+ "fmt"
+ gast "github.com/yuin/goldmark/ast"
+ "strings"
+)
+
+// Alignment is a text alignment of table cells.
+type Alignment int
+
+const (
+ // AlignLeft indicates text should be left justified.
+ AlignLeft Alignment = iota + 1
+
+ // AlignRight indicates text should be right justified.
+ AlignRight
+
+ // AlignCenter indicates text should be centered.
+ AlignCenter
+
+ // AlignNone indicates text should be aligned by default manner.
+ AlignNone
+)
+
+func (a Alignment) String() string {
+ switch a {
+ case AlignLeft:
+ return "left"
+ case AlignRight:
+ return "right"
+ case AlignCenter:
+ return "center"
+ case AlignNone:
+ return "none"
+ }
+ return ""
+}
+
+// A Table struct represents a table of Markdown(GFM) text.
+type Table struct {
+ gast.BaseBlock
+
+ // Alignments returns alignments of the columns.
+ Alignments []Alignment
+}
+
+// Dump implements Node.Dump
+func (n *Table) Dump(source []byte, level int) {
+ gast.DumpHelper(n, source, level, nil, func(level int) {
+ indent := strings.Repeat(" ", level)
+ fmt.Printf("%sAlignments {\n", indent)
+ for i, alignment := range n.Alignments {
+ indent2 := strings.Repeat(" ", level+1)
+ fmt.Printf("%s%s", indent2, alignment.String())
+ if i != len(n.Alignments)-1 {
+ fmt.Println("")
+ }
+ }
+ fmt.Printf("\n%s}\n", indent)
+ })
+}
+
+// KindTable is a NodeKind of the Table node.
+var KindTable = gast.NewNodeKind("Table")
+
+// Kind implements Node.Kind.
+func (n *Table) Kind() gast.NodeKind {
+ return KindTable
+}
+
+// NewTable returns a new Table node.
+func NewTable() *Table {
+ return &Table{
+ Alignments: []Alignment{},
+ }
+}
+
+// A TableRow struct represents a table row of Markdown(GFM) text.
+type TableRow struct {
+ gast.BaseBlock
+ Alignments []Alignment
+}
+
+// Dump implements Node.Dump.
+func (n *TableRow) Dump(source []byte, level int) {
+ gast.DumpHelper(n, source, level, nil, nil)
+}
+
+// KindTableRow is a NodeKind of the TableRow node.
+var KindTableRow = gast.NewNodeKind("TableRow")
+
+// Kind implements Node.Kind.
+func (n *TableRow) Kind() gast.NodeKind {
+ return KindTableRow
+}
+
+// NewTableRow returns a new TableRow node.
+func NewTableRow(alignments []Alignment) *TableRow {
+ return &TableRow{Alignments: alignments}
+}
+
+// A TableHeader struct represents a table header of Markdown(GFM) text.
+type TableHeader struct {
+ gast.BaseBlock
+ Alignments []Alignment
+}
+
+// KindTableHeader is a NodeKind of the TableHeader node.
+var KindTableHeader = gast.NewNodeKind("TableHeader")
+
+// Kind implements Node.Kind.
+func (n *TableHeader) Kind() gast.NodeKind {
+ return KindTableHeader
+}
+
+// Dump implements Node.Dump.
+func (n *TableHeader) Dump(source []byte, level int) {
+ gast.DumpHelper(n, source, level, nil, nil)
+}
+
+// NewTableHeader returns a new TableHeader node.
+func NewTableHeader(row *TableRow) *TableHeader {
+ n := &TableHeader{}
+ for c := row.FirstChild(); c != nil; {
+ next := c.NextSibling()
+ n.AppendChild(n, c)
+ c = next
+ }
+ return n
+}
+
+// A TableCell struct represents a table cell of a Markdown(GFM) text.
+type TableCell struct {
+ gast.BaseBlock
+ Alignment Alignment
+}
+
+// Dump implements Node.Dump.
+func (n *TableCell) Dump(source []byte, level int) {
+ gast.DumpHelper(n, source, level, nil, nil)
+}
+
+// KindTableCell is a NodeKind of the TableCell node.
+var KindTableCell = gast.NewNodeKind("TableCell")
+
+// Kind implements Node.Kind.
+func (n *TableCell) Kind() gast.NodeKind {
+ return KindTableCell
+}
+
+// NewTableCell returns a new TableCell node.
+func NewTableCell() *TableCell {
+ return &TableCell{
+ Alignment: AlignNone,
+ }
+}
diff --git a/vendor/github.com/yuin/goldmark/extension/ast/tasklist.go b/vendor/github.com/yuin/goldmark/extension/ast/tasklist.go
new file mode 100644
index 000000000..670cc1495
--- /dev/null
+++ b/vendor/github.com/yuin/goldmark/extension/ast/tasklist.go
@@ -0,0 +1,35 @@
+package ast
+
+import (
+ "fmt"
+ gast "github.com/yuin/goldmark/ast"
+)
+
+// A TaskCheckBox struct represents a checkbox of a task list.
+type TaskCheckBox struct {
+ gast.BaseInline
+ IsChecked bool
+}
+
+// Dump implements Node.Dump.
+func (n *TaskCheckBox) Dump(source []byte, level int) {
+ m := map[string]string{
+ "Checked": fmt.Sprintf("%v", n.IsChecked),
+ }
+ gast.DumpHelper(n, source, level, m, nil)
+}
+
+// KindTaskCheckBox is a NodeKind of the TaskCheckBox node.
+var KindTaskCheckBox = gast.NewNodeKind("TaskCheckBox")
+
+// Kind implements Node.Kind.
+func (n *TaskCheckBox) Kind() gast.NodeKind {
+ return KindTaskCheckBox
+}
+
+// NewTaskCheckBox returns a new TaskCheckBox node.
+func NewTaskCheckBox(checked bool) *TaskCheckBox {
+ return &TaskCheckBox{
+ IsChecked: checked,
+ }
+}