diff --git a/org/html_writer.go b/org/html_writer.go index 94f3c8b..faba5f0 100644 --- a/org/html_writer.go +++ b/org/html_writer.go @@ -151,6 +151,16 @@ func (w *HTMLWriter) WriteFootnotes(d *Document) { w.WriteString(`
` + "\n") w.WriteString(`
` + "\n") for i, definition := range w.footnotes.list { + if definition == nil { + name := "" + for k, v := range w.footnotes.mapping { + if v == i { + name = k + } + } + w.log.Printf("Missing footnote definition for [fn:%s] (#%d)", name, i) + continue + } w.WriteString(`
` + "\n") w.WriteString(fmt.Sprintf(`%d`, i, i, i) + "\n") w.WriteString(`
` + "\n") diff --git a/org/testdata/footnotes.html b/org/testdata/footnotes.html index 4e50b35..abba22d 100644 --- a/org/testdata/footnotes.html +++ b/org/testdata/footnotes.html @@ -36,15 +36,20 @@ Footnote definitions are not printed where they appear. Rather, they are gathered and exported at the end of the document in the footnote section. 5

+
  • +

    +footnotes that reference a non-existant definition are rendered but log a warning 6 +

    +
  • Footnotes

    -Please note that the footnotes section is not automatically excluded from the export like in emacs. 6 +Please note that the footnotes section is not automatically excluded from the export like in emacs. 7

    -this is not part of 6 anymore as there are 2 blank lines in between! +this is not part of 7 anymore as there are 2 blank lines in between!


    @@ -147,7 +152,7 @@ Rather, it will be somewhere down below in the footnotes section.
    -6 +7

    There's multiple reasons for that. Among others, doing so requires i18n (to recognize the section) and silently diff --git a/org/testdata/footnotes.org b/org/testdata/footnotes.org index b613bdc..44a9019 100644 --- a/org/testdata/footnotes.org +++ b/org/testdata/footnotes.org @@ -5,6 +5,7 @@ - anonymous inline footnotes are also supported via [fn::the anonymous inline footnote definition]. - Footnote definitions are not printed where they appear. Rather, they are gathered and exported at the end of the document in the footnote section. [fn:4] +- footnotes that reference a non-existant definition are rendered but log a warning [fn:does-not-exist] [fn:4] so this definition will not be at the end of this section in the exported document. Rather, it will be somewhere down below in the footnotes section. diff --git a/org/testdata/footnotes.pretty_org b/org/testdata/footnotes.pretty_org index b613bdc..44a9019 100644 --- a/org/testdata/footnotes.pretty_org +++ b/org/testdata/footnotes.pretty_org @@ -5,6 +5,7 @@ - anonymous inline footnotes are also supported via [fn::the anonymous inline footnote definition]. - Footnote definitions are not printed where they appear. Rather, they are gathered and exported at the end of the document in the footnote section. [fn:4] +- footnotes that reference a non-existant definition are rendered but log a warning [fn:does-not-exist] [fn:4] so this definition will not be at the end of this section in the exported document. Rather, it will be somewhere down below in the footnotes section.