Fix footnotes starting with empty line

This commit is contained in:
Niklas Fasching 2018-12-03 00:35:12 +01:00
parent 3c2e9ed204
commit d5665fb21c
5 changed files with 26 additions and 11 deletions

View file

@ -148,8 +148,18 @@ func (w *OrgWriter) writeFootnotes(d *Document) {
}
}
func isEmptyLineParagraph(n Node) bool {
if p, _ := n.(Paragraph); len(p.Children) == 1 {
return len(p.Children[0].(Line).Children) == 0
}
return false
}
func (w *OrgWriter) writeFootnoteDefinition(f FootnoteDefinition) {
w.WriteString(fmt.Sprintf("[fn:%s] ", f.Name))
w.WriteString(fmt.Sprintf("[fn:%s]", f.Name))
if !(len(f.Children) >= 1 && isEmptyLineParagraph(f.Children[0])) {
w.WriteString(" ")
}
w.writeNodes(f.Children...)
}