Skip to content

Commit 8351691

Browse files
Regenerate README.md
1 parent 0fff5e7 commit 8351691

File tree

1 file changed

+49
-25
lines changed

1 file changed

+49
-25
lines changed

README.md

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ This results in footnotes with support for multiple paragraphs, that work withou
6363

6464
## Implementation
6565

66-
In [Org mode 9.6.5](https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ox-html.el?h=release_9.6.5#n1858), the `org-html-footnote-section` looks like this:
66+
In [Org mode 9.7.34](https://cgit.git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ox-html.el?h=release_9.7.34#n1870) the `org-html-footnote-section` looks like this:
6767

6868
```emacs-lisp
6969
(defun org-html-footnote-section (info)
@@ -80,13 +80,25 @@ INFO is a plist used as a communication channel."
8080
(mapconcat
8181
(lambda (definition)
8282
(pcase definition
83-
(`(,n ,_ ,def)
83+
(`(,n ,label ,def)
84+
;; Do not assign number labels as they appear in Org mode
85+
;; - the footnotes are re-numbered by
86+
;; `org-export-get-footnote-number'. If the label is not
87+
;; a number, keep it.
88+
(when (and (stringp label)
89+
(equal label (number-to-string (string-to-number label))))
90+
(setq label nil))
91+
;; `org-export-collect-footnote-definitions' can return
92+
;; two kinds of footnote definitions: inline and blocks.
93+
;; Since this should not make any difference in the HTML
94+
;; output, we wrap the inline definitions within
95+
;; a "footpara" class paragraph.
8496
(let ((inline? (not (org-element-map def org-element-all-elements
8597
#'identity nil t)))
8698
(anchor (org-html--anchor
87-
(format "fn.%d" n)
99+
(format "fn.%s" (or label n))
88100
n
89-
(format " class=\"footnum\" href=\"#fnr.%d\" role=\"doc-backlink\"" n)
101+
(format " class=\"footnum\" href=\"#fnr.%s\" role=\"doc-backlink\"" (or label n))
90102
info))
91103
(contents (org-trim (org-export-data def info))))
92104
(format "<div class=\"footdef\">%s %s</div>\n"
@@ -102,12 +114,24 @@ INFO is a plist used as a communication channel."
102114
The function returns nothing if there are no footnotes in the document, or uses the format set in `:html-footnotes-section` to print each footnote. The interesting part is executed for each footnote, and wraps each footnote in a `div` element with a link back to where the footnote is referenced from:
103115

104116
```emacs-lisp
117+
;; Do not assign number labels as they appear in Org mode
118+
;; - the footnotes are re-numbered by
119+
;; `org-export-get-footnote-number'. If the label is not
120+
;; a number, keep it.
121+
(when (and (stringp label)
122+
(equal label (number-to-string (string-to-number label))))
123+
(setq label nil))
124+
;; `org-export-collect-footnote-definitions' can return
125+
;; two kinds of footnote definitions: inline and blocks.
126+
;; Since this should not make any difference in the HTML
127+
;; output, we wrap the inline definitions within
128+
;; a "footpara" class paragraph.
105129
(let ((inline? (not (org-element-map def org-element-all-elements
106130
#'identity nil t)))
107131
(anchor (org-html--anchor
108-
(format "fn.%d" n)
132+
(format "fn.%s" (or label n))
109133
n
110-
(format " class=\"footnum\" href=\"#fnr.%d\" role=\"doc-backlink\"" n)
134+
(format " class=\"footnum\" href=\"#fnr.%s\" role=\"doc-backlink\"" (or label n))
111135
info))
112136
(contents (org-trim (org-export-data def info))))
113137
(format "<div class=\"footdef\">%s %s</div>\n"
@@ -157,25 +181,25 @@ The updated copy is defined as `org-html-markdown-style-footnotes--section`:
157181
```emacs-lisp
158182
(defun org-html-markdown-style-footnotes--section (orig-fun info)
159183
(if org-html-markdown-style-footnotes
160-
(pcase (org-export-collect-footnote-definitions info)
161-
(`nil nil)
162-
(definitions
163-
(format
164-
(plist-get info :html-footnotes-section)
165-
(org-html--translate "Footnotes" info)
166-
(format
167-
"<ol>\n%s</ol>\n"
168-
(mapconcat
169-
(lambda (definition)
170-
(pcase definition
171-
(`(,n ,_ ,def)
172-
(format
173-
"<li id=\"fn.%d\" class=\"footdef\" role=\"doc-footnote\" tabindex=\"-1\">%s %s</li>\n"
174-
n
175-
(org-trim (org-export-data def info))
176-
(format "<a href=\"#fnr.%d\" role=\"doc-backlink\">↩&#65038;</a>" n)))))
177-
definitions
178-
"\n")))))
184+
(pcase (org-export-collect-footnote-definitions info)
185+
(`nil nil)
186+
(definitions
187+
(format
188+
(plist-get info :html-footnotes-section)
189+
(org-html--translate "Footnotes" info)
190+
(format
191+
"<ol>\n%s</ol>\n"
192+
(mapconcat
193+
(lambda (definition)
194+
(pcase definition
195+
(`(,n ,label ,def)
196+
(format
197+
"<li id=\"fn.%s\" class=\"footdef\" role=\"doc-footnote\" tabindex=\"-1\">%s %s</li>\n"
198+
(or label n)
199+
(org-trim (org-export-data def info))
200+
(format "<a href=\"#fnr.%s\" role=\"doc-backlink\">↩&#65038;</a>" (or label n))))))
201+
definitions
202+
"\n")))))
179203
(funcall orig-fun info)))
180204
```
181205

0 commit comments

Comments
 (0)