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 {
|
type FootnoteBackLink struct {
|
||||||
gast.BaseInline
|
gast.BaseInline
|
||||||
Index int
|
Index int
|
||||||
|
Ref []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dump implements Node.Dump.
|
// Dump implements Node.Dump.
|
||||||
|
|
@ -59,9 +60,10 @@ func (n *FootnoteBackLink) Kind() gast.NodeKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFootnoteBackLink returns a new FootnoteBackLink node.
|
// NewFootnoteBackLink returns a new FootnoteBackLink node.
|
||||||
func NewFootnoteBackLink(index int) *FootnoteBackLink {
|
func NewFootnoteBackLink(index int, ref []byte) *FootnoteBackLink {
|
||||||
return &FootnoteBackLink{
|
return &FootnoteBackLink{
|
||||||
Index: index,
|
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) {
|
if fc := container.LastChild(); fc != nil && gast.IsParagraph(fc) {
|
||||||
container = fc
|
container = fc
|
||||||
}
|
}
|
||||||
index := footnote.(*ast.Footnote).Index
|
n := footnote.(*ast.Footnote)
|
||||||
if index < 0 {
|
if n.Index < 0 {
|
||||||
list.RemoveChild(list, footnote)
|
list.RemoveChild(list, footnote)
|
||||||
} else {
|
} else {
|
||||||
container.AppendChild(container, ast.NewFootnoteBackLink(index))
|
backlink := ast.NewFootnoteBackLink(n.Index, n.Ref)
|
||||||
|
container.AppendChild(container, backlink)
|
||||||
}
|
}
|
||||||
footnote = next
|
footnote = next
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue