footnote.go (3300B)
1 package ast 2 3 import ( 4 "fmt" 5 6 gast "github.com/yuin/goldmark/ast" 7 ) 8 9 // A FootnoteLink struct represents a link to a footnote of Markdown 10 // (PHP Markdown Extra) text. 11 type FootnoteLink struct { 12 gast.BaseInline 13 Index int 14 RefCount int 15 RefIndex int 16 } 17 18 // Dump implements Node.Dump. 19 func (n *FootnoteLink) Dump(source []byte, level int) { 20 m := map[string]string{} 21 m["Index"] = fmt.Sprintf("%v", n.Index) 22 m["RefCount"] = fmt.Sprintf("%v", n.RefCount) 23 m["RefIndex"] = fmt.Sprintf("%v", n.RefIndex) 24 gast.DumpHelper(n, source, level, m, nil) 25 } 26 27 // KindFootnoteLink is a NodeKind of the FootnoteLink node. 28 var KindFootnoteLink = gast.NewNodeKind("FootnoteLink") 29 30 // Kind implements Node.Kind. 31 func (n *FootnoteLink) Kind() gast.NodeKind { 32 return KindFootnoteLink 33 } 34 35 // NewFootnoteLink returns a new FootnoteLink node. 36 func NewFootnoteLink(index int) *FootnoteLink { 37 return &FootnoteLink{ 38 Index: index, 39 RefCount: 0, 40 RefIndex: 0, 41 } 42 } 43 44 // A FootnoteBacklink struct represents a link to a footnote of Markdown 45 // (PHP Markdown Extra) text. 46 type FootnoteBacklink struct { 47 gast.BaseInline 48 Index int 49 RefCount int 50 RefIndex int 51 } 52 53 // Dump implements Node.Dump. 54 func (n *FootnoteBacklink) Dump(source []byte, level int) { 55 m := map[string]string{} 56 m["Index"] = fmt.Sprintf("%v", n.Index) 57 m["RefCount"] = fmt.Sprintf("%v", n.RefCount) 58 m["RefIndex"] = fmt.Sprintf("%v", n.RefIndex) 59 gast.DumpHelper(n, source, level, m, nil) 60 } 61 62 // KindFootnoteBacklink is a NodeKind of the FootnoteBacklink node. 63 var KindFootnoteBacklink = gast.NewNodeKind("FootnoteBacklink") 64 65 // Kind implements Node.Kind. 66 func (n *FootnoteBacklink) Kind() gast.NodeKind { 67 return KindFootnoteBacklink 68 } 69 70 // NewFootnoteBacklink returns a new FootnoteBacklink node. 71 func NewFootnoteBacklink(index int) *FootnoteBacklink { 72 return &FootnoteBacklink{ 73 Index: index, 74 RefCount: 0, 75 RefIndex: 0, 76 } 77 } 78 79 // A Footnote struct represents a footnote of Markdown 80 // (PHP Markdown Extra) text. 81 type Footnote struct { 82 gast.BaseBlock 83 Ref []byte 84 Index int 85 } 86 87 // Dump implements Node.Dump. 88 func (n *Footnote) Dump(source []byte, level int) { 89 m := map[string]string{} 90 m["Index"] = fmt.Sprintf("%v", n.Index) 91 m["Ref"] = fmt.Sprintf("%s", n.Ref) 92 gast.DumpHelper(n, source, level, m, nil) 93 } 94 95 // KindFootnote is a NodeKind of the Footnote node. 96 var KindFootnote = gast.NewNodeKind("Footnote") 97 98 // Kind implements Node.Kind. 99 func (n *Footnote) Kind() gast.NodeKind { 100 return KindFootnote 101 } 102 103 // NewFootnote returns a new Footnote node. 104 func NewFootnote(ref []byte) *Footnote { 105 return &Footnote{ 106 Ref: ref, 107 Index: -1, 108 } 109 } 110 111 // A FootnoteList struct represents footnotes of Markdown 112 // (PHP Markdown Extra) text. 113 type FootnoteList struct { 114 gast.BaseBlock 115 Count int 116 } 117 118 // Dump implements Node.Dump. 119 func (n *FootnoteList) Dump(source []byte, level int) { 120 m := map[string]string{} 121 m["Count"] = fmt.Sprintf("%v", n.Count) 122 gast.DumpHelper(n, source, level, m, nil) 123 } 124 125 // KindFootnoteList is a NodeKind of the FootnoteList node. 126 var KindFootnoteList = gast.NewNodeKind("FootnoteList") 127 128 // Kind implements Node.Kind. 129 func (n *FootnoteList) Kind() gast.NodeKind { 130 return KindFootnoteList 131 } 132 133 // NewFootnoteList returns a new FootnoteList node. 134 func NewFootnoteList() *FootnoteList { 135 return &FootnoteList{ 136 Count: 0, 137 } 138 }