mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
parent
fbd164be52
commit
70ad9d5b30
2 changed files with 7 additions and 4 deletions
|
|
@ -41,6 +41,7 @@ func NewFootnoteLink(index int, ref []byte) *FootnoteLink {
|
|||
type FootnoteBackLink struct {
|
||||
gast.BaseInline
|
||||
Index int
|
||||
Ref []byte
|
||||
}
|
||||
|
||||
// Dump implements Node.Dump.
|
||||
|
|
@ -59,9 +60,10 @@ func (n *FootnoteBackLink) Kind() gast.NodeKind {
|
|||
}
|
||||
|
||||
// NewFootnoteBackLink returns a new FootnoteBackLink node.
|
||||
func NewFootnoteBackLink(index int) *FootnoteBackLink {
|
||||
func NewFootnoteBackLink(index int, ref []byte) *FootnoteBackLink {
|
||||
return &FootnoteBackLink{
|
||||
Index: index,
|
||||
Ref: ref,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -194,11 +194,12 @@ func (a *footnoteASTTransformer) Transform(node *gast.Document, reader text.Read
|
|||
if fc := container.LastChild(); fc != nil && gast.IsParagraph(fc) {
|
||||
container = fc
|
||||
}
|
||||
index := footnote.(*ast.Footnote).Index
|
||||
if index < 0 {
|
||||
n := footnote.(*ast.Footnote)
|
||||
if n.Index < 0 {
|
||||
list.RemoveChild(list, footnote)
|
||||
} else {
|
||||
container.AppendChild(container, ast.NewFootnoteBackLink(index))
|
||||
backlink := ast.NewFootnoteBackLink(n.Index, n.Ref)
|
||||
container.AppendChild(container, backlink)
|
||||
}
|
||||
footnote = next
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue