diff --git a/lisp/org-exp.el b/lisp/org-exp.el index a055bac..99b3a64 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -1094,7 +1094,9 @@ on this string to produce the exported version." ;; Normalize footnotes (when (plist-get parameters :footnotes) - (org-footnote-normalize nil t)) + (if htmlp + (org-footnote-normalize nil org-footnote-section) + (org-footnote-normalize nil t))) ;; Find all headings and compute the targets for them (setq target-alist (org-export-define-heading-targets target-alist)) diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index 88ffd6e..027856e 100644 --- a/lisp/org-footnote.el +++ b/lisp/org-footnote.el @@ -478,14 +478,24 @@ referenced sequence." (not sort-only) ; this is normalization for-preprocessor) ; the is the preprocessor ;; Insert the footnotes together in one place - (progn - (setq def - (mapconcat - (lambda (x) - (format "[%s] %s" (nth (if sort-only 0 1) x) - (org-trim (nth 2 x)))) - ref-table "\n\n")) - (if ref-table (insert "\n" def "\n\n"))) + (if for-preprocessor + (progn + (message "%s" ref-table) + (setq def + (mapconcat + (lambda (x) + (format "[%s] %s" (nth (if sort-only 0 1) x) + (org-trim (nth 2 x)))) + ref-table "\n\n")) + (if ref-table (insert "\n" def "\n\n"))) + (mapc (lambda (entry) + (when (car entry) + (goto-char (point-min)) + (when (re-search-forward (format ".\\[%s[]:]" (regexp-quote (nth 1 entry))) + nil t) + (org-footnote-goto-local-insertion-point) + (insert (format "\n\n[%s] %s" (nth 1 entry) (nth 2 entry)))))) + ref-table)) ;; Insert each footnote near the first reference ;; Happens only in Org files with no special footnote section, ;; and only when doing sorting diff --git a/lisp/org-html.el b/lisp/org-html.el index 9a5d225..3dedab9 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -1676,16 +1676,19 @@ lang=\"%s\" xml:lang=\"%s\"> ;; the to close the last text-... div. (when (and (> umax 0) first-heading-pos) (insert "\n")) - (save-excursion - (goto-char (point-min)) - (while (re-search-forward "

[^\000]*?\\(

\\|\\'\\)" nil t) - (push (match-string 0) footnotes) - (replace-match "" t t))) - (when footnotes - (insert (format org-export-html-footnotes-section - (nth 4 lang-words) - (mapconcat 'identity (nreverse footnotes) "\n")) - "\n")) + (when org-footnote-section + ;; Move all the footnotes into a footnotes section + (save-excursion + (goto-char (point-min)) + (while (re-search-forward "

[^\000]*?\\(

\\|\\'\\)" nil t) + (push (match-string 0) footnotes) + (replace-match "" t t))) + (when footnotes + (insert (format org-export-html-footnotes-section + (nth 4 lang-words) + (mapconcat 'identity (nreverse footnotes) "\n")) + "\n"))) + (let ((bib (org-export-html-get-bibliography))) (when bib (insert "\n" bib "\n")))