From 777899c803b045b6a19734b4975c0a8401a76a40 Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Sun, 7 Jul 2019 21:25:42 +0200 Subject: [PATCH] HTML export: Update footnote numbering to start with 1 I went with 0 based numbering because it was easier but after looking at the results 0 based numbering looks bad to me... let's start with 1 like everyone else as it's just a few more lines of code. --- org/html_writer.go | 8 +++++--- org/testdata/footnotes.html | 30 +++++++++++++++--------------- org/testdata/misc.html | 6 +++--- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/org/html_writer.go b/org/html_writer.go index faba5f0..05713e6 100644 --- a/org/html_writer.go +++ b/org/html_writer.go @@ -151,6 +151,7 @@ func (w *HTMLWriter) WriteFootnotes(d *Document) { w.WriteString(`
` + "\n") w.WriteString(`
` + "\n") for i, definition := range w.footnotes.list { + id := i + 1 if definition == nil { name := "" for k, v := range w.footnotes.mapping { @@ -158,11 +159,11 @@ func (w *HTMLWriter) WriteFootnotes(d *Document) { name = k } } - w.log.Printf("Missing footnote definition for [fn:%s] (#%d)", name, i) + w.log.Printf("Missing footnote definition for [fn:%s] (#%d)", name, id) continue } w.WriteString(`
` + "\n") - w.WriteString(fmt.Sprintf(`%d`, i, i, i) + "\n") + w.WriteString(fmt.Sprintf(`%d`, id, id, id) + "\n") w.WriteString(`
` + "\n") WriteNodes(w, definition.Children...) w.WriteString("
\n
\n") @@ -262,7 +263,8 @@ func (w *HTMLWriter) WriteFootnoteLink(l FootnoteLink) { if !w.document.GetOption("f") { return } - id := w.footnotes.add(l) + i := w.footnotes.add(l) + id := i + 1 w.WriteString(fmt.Sprintf(`%d`, id, id, id)) } diff --git a/org/testdata/footnotes.html b/org/testdata/footnotes.html index abba22d..7575443 100644 --- a/org/testdata/footnotes.html +++ b/org/testdata/footnotes.html @@ -12,33 +12,33 @@ Using some footnotes @@ -46,16 +46,16 @@ footnotes that reference a non-existant definition are rendered but log a warnin Footnotes

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

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


-0 +1

https://www.example.com @@ -110,7 +110,7 @@ and tables

-1 +2

Footnotes break after two consecutive empty lines - just like paragraphs - see https://orgmode.org/worg/dev/org-syntax.html. @@ -119,7 +119,7 @@ This shouldn't happen when the definition line and the line after that are e

-2 +3

yolo @@ -127,7 +127,7 @@ yolo

-3 +4

the inline footnote definition @@ -135,7 +135,7 @@ the inline footnote definition

-4 +5

the anonymous inline footnote definition @@ -143,7 +143,7 @@ the anonymous inline footnote definition

-5 +6

so this definition will not be at the end of this section in the exported document. @@ -152,7 +152,7 @@ Rather, it will be somewhere down below in the footnotes section.

-7 +8

There's multiple reasons for that. Among others, doing so requires i18n (to recognize the section) and silently diff --git a/org/testdata/misc.html b/org/testdata/misc.html index a925348..d6a389f 100644 --- a/org/testdata/misc.html +++ b/org/testdata/misc.html @@ -413,7 +413,7 @@ src/example/export blocks should not be converted! #87: Markup in footnotes is rendered literally

-footnotes can contain markup - and other elements and stuff 0 1 +footnotes can contain markup - and other elements and stuff 1 2

DONE @@ -482,7 +482,7 @@ Footnotes
-0 +1

a footnote with markup @@ -502,7 +502,7 @@ because that's possible

-1 +2

that also goes for inline footnote definitions