all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [BUG] HTML export does not preserve footnote label [9.6.15 (release_9.6.15 @ /usr/local/share/emacs/30.0.50/lisp/org/)]
@ 2024-04-05  8:48 Protesilaos Stavrou
  2024-04-05 14:33 ` Ihor Radchenko
  0 siblings, 1 reply; 19+ messages in thread
From: Protesilaos Stavrou @ 2024-04-05  8:48 UTC (permalink / raw)
  To: emacs-orgmode

Dear maintainer,

I have an Org file with contents like the following:

    This is a test 1 [fn:n24aa:These are the contents] and here is more.

When I do an HTML export, the footnote's label (n24aa) is not preserved
in the exported HTML. Is this intended behaviour? I was expecting it to
keep the label as a user-defined unique identifier.

I looked into the ox.el and noticed that the export data does include
the labels. But 'org-html-footnote-reference' does not have a call to
get the label: it assigns a number outright. To experiment with
retrieving the data, I tried this:

    ;; PROOF-OF-CONCEPT that works for footnote references but not
    ;; footnote definitions
    (defun org-export-get-footnote-label (footnote)
      (org-element-property :label footnote))

    (defun org-html-footnote-reference (footnote-reference _contents info)
      "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
    CONTENTS is nil.  INFO is a plist holding contextual information."
      (concat
       ;; Insert separator between two footnotes in a row.
       (let ((prev (org-export-get-previous-element footnote-reference info)))
         (when (eq (org-element-type prev) 'footnote-reference)
           (plist-get info :html-footnote-separator)))
       (let* ((n (or
                  (org-export-get-footnote-label footnote-reference)
                  (org-export-get-footnote-number footnote-reference info)))
              (id (format "fnr.%s%s"
                          n
                          (if (org-export-footnote-first-reference-p
                               footnote-reference info)
                              ""
                            ".100"))))
         (format
          (plist-get info :html-footnote-format)
          (org-html--anchor
           id n (format " class=\"footref\" href=\"#fn.%s\" role=\"doc-backlink\"" n) info)))))

Can we have footnotes with their label preserved? Or maybe is this going
to break a lot of functionality? I am aware the above not work for
footnote definitions, as those also get the number.

I am happy to keep studying the export infrastructure if you give me
some pointers.

Thank you for your time and for maintaining this wonderful project!

All the best,
Protesilaos (or simply "Prot")

* *  *

Emacs  : GNU Emacs 30.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.16.0)
 of 2024-04-03
Package: Org mode version 9.6.15 (release_9.6.15 @ /usr/local/share/emacs/30.0.50/lisp/org/)

-- 
Protesilaos Stavrou
https://protesilaos.com


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-05-03 18:11 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-05  8:48 [BUG] HTML export does not preserve footnote label [9.6.15 (release_9.6.15 @ /usr/local/share/emacs/30.0.50/lisp/org/)] Protesilaos Stavrou
2024-04-05 14:33 ` Ihor Radchenko
2024-04-10  7:19   ` Protesilaos Stavrou
2024-04-10 14:31     ` Ihor Radchenko
2024-04-12  7:05       ` Protesilaos Stavrou
2024-04-13 14:00         ` Ihor Radchenko
2024-04-26  7:55           ` Protesilaos Stavrou
2024-04-26  8:17             ` Protesilaos Stavrou
2024-04-26  9:53               ` Max Nikulin
2024-05-03  6:59                 ` Protesilaos Stavrou
2024-05-03 10:53                   ` Max Nikulin
2024-05-03 11:14                     ` Ihor Radchenko
2024-05-03 17:29                       ` Max Nikulin
2024-04-28 10:37               ` Ihor Radchenko
2024-05-03  9:07                 ` Protesilaos Stavrou
2024-05-03 11:28                   ` Ihor Radchenko
2024-04-28 10:22             ` Ihor Radchenko
2024-05-03  7:00               ` Protesilaos Stavrou
2024-04-28 10:36           ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.