Refactor Footnotes: Exclude footnotes heading during export, not parsing

Until now the footnotes section was parsed but not included in the resulting
AST - his required rebuilding it in the OrgWriter. It feels cleaner to include
it in the AST and only exclude it in the export
This commit is contained in:
Niklas Fasching 2018-12-17 13:08:35 +01:00
parent ced166dc18
commit ac2597af4c
5 changed files with 17 additions and 31 deletions

View file

@ -31,9 +31,7 @@ func NewOrgWriter() *OrgWriter {
}
func (w *OrgWriter) before(d *Document) {}
func (w *OrgWriter) after(d *Document) {
w.writeFootnotes(d)
}
func (w *OrgWriter) after(d *Document) {}
func (w *OrgWriter) emptyClone() *OrgWriter {
wcopy := *w
@ -160,19 +158,6 @@ func (w *OrgWriter) writeDrawer(d Drawer) {
w.WriteString(w.indent + ":END:\n")
}
func (w *OrgWriter) writeFootnotes(d *Document) {
fs := d.Footnotes
if len(fs.Definitions) == 0 {
return
}
w.WriteString("* " + fs.Title + "\n")
for _, definition := range fs.Ordered() {
if !definition.Inline {
w.writeNodes(definition)
}
}
}
func (w *OrgWriter) writeFootnoteDefinition(f FootnoteDefinition) {
w.WriteString(fmt.Sprintf("[fn:%s]", f.Name))
if !(len(f.Children) >= 1 && isEmptyLineParagraph(f.Children[0])) {