Fix footnote ordering and some other bugs

This commit is contained in:
Niklas Fasching 2018-12-02 20:09:40 +01:00
parent b1f9bfc9e9
commit d5bf4317b2
7 changed files with 105 additions and 28 deletions

View file

@ -114,19 +114,11 @@ func (d *Document) parseRegularLinkOrFootnoteReference(input string, start int)
func (d *Document) parseFootnoteReference(input string, start int) (int, Node) {
if m := footnoteRegexp.FindStringSubmatch(input[start:]); m != nil {
name, definition := m[1], m[3]
seen, link := false, FootnoteLink{name, nil}
for _, otherName := range d.Footnotes.Order {
if name == otherName {
seen = true
}
}
if !seen {
d.Footnotes.Order = append(d.Footnotes.Order, name)
}
link := FootnoteLink{name, nil}
if definition != "" {
link.Definition = &FootnoteDefinition{name, d.parseInline(definition), true}
d.Footnotes.Definitions[name] = *link.Definition
}
d.Footnotes.add(name, link.Definition)
return len(m[0]), link
}
return 0, nil