Fix inline footnote definition parsing

footnote definition descriptions are always elements - not just raw inline
markup. we'll just wrap the description in a paragraph
This commit is contained in:
Niklas Fasching 2018-12-02 23:26:24 +01:00
parent d5bf4317b2
commit 0df8bc541b
2 changed files with 4 additions and 2 deletions

View file

@ -116,7 +116,8 @@ func (d *Document) parseFootnoteReference(input string, start int) (int, Node) {
name, definition := m[1], m[3] name, definition := m[1], m[3]
link := FootnoteLink{name, nil} link := FootnoteLink{name, nil}
if definition != "" { if definition != "" {
link.Definition = &FootnoteDefinition{name, d.parseInline(definition), true} paragraph := Paragraph{[]Node{Line{d.parseInline(definition)}}}
link.Definition = &FootnoteDefinition{name, []Node{paragraph}, true}
} }
d.Footnotes.add(name, link.Definition) d.Footnotes.add(name, link.Definition)
return len(m[0]), link return len(m[0]), link

View file

@ -237,7 +237,8 @@ func (w *OrgWriter) writeFootnoteLink(l FootnoteLink) {
w.WriteString("[fn:" + l.Name) w.WriteString("[fn:" + l.Name)
if l.Definition != nil { if l.Definition != nil {
w.WriteString(":") w.WriteString(":")
w.writeNodes(l.Definition.Children...) line := l.Definition.Children[0].(Paragraph).Children[0].(Line)
w.writeNodes(line.Children...)
} }
w.WriteString("]") w.WriteString("]")
} }