Improve footnote handling

- Footnotes separator rather than headline to get around i18n
- Warn on footnote redefinition
- Do not export footnote definitions at point of definition, only in the
  footnote section.
- Do not automatically exclude Footnotes section to get around possibly hiding
  other content of such a section - and i18n.
  The user has the choice of explicitly hiding the section via a :noexport:
  tag.

and some other refactoring
This commit is contained in:
Niklas Fasching 2018-12-26 15:23:23 +01:00
parent beff0c0d8a
commit eb7db9b968
11 changed files with 114 additions and 60 deletions

View file

@ -3,6 +3,7 @@ package org
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
@ -175,10 +176,11 @@ func (w *OrgWriter) writePropertyDrawer(d PropertyDrawer) {
func (w *OrgWriter) writeFootnoteDefinition(f FootnoteDefinition) {
w.WriteString(fmt.Sprintf("[fn:%s]", f.Name))
if !(len(f.Children) >= 1 && isEmptyLineParagraph(f.Children[0])) {
content := w.nodesAsString(f.Children...)
if content != "" && !unicode.IsSpace(rune(content[0])) {
w.WriteString(" ")
}
w.writeNodes(f.Children...)
w.WriteString(content)
}
func (w *OrgWriter) writeParagraph(p Paragraph) {