From: Protesilaos Stavrou <info@protesilaos.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: [BUG] HTML export does not preserve footnote label [9.6.15 (release_9.6.15 @ /usr/local/share/emacs/30.0.50/lisp/org/)]
Date: Fri, 26 Apr 2024 11:17:14 +0300 [thread overview]
Message-ID: <87a5lgv8qd.fsf@protesilaos.com> (raw)
In-Reply-To: <87cyqcv9q1.fsf@protesilaos.com>
[-- Attachment #1: Type: text/plain, Size: 984 bytes --]
Hello again!
A follow-up on the patches below:
> From: Protesilaos Stavrou <info@protesilaos.com>
> Date: Fri, 26 Apr 2024 10:55:50 +0300
> [... 41 lines elided]
> Thank you! I just tried it. I encountered two problems with it, which I
> am addressing with the two attached patches (feel free to modify as
> needed). In short:
>
> 1. The footnote definitions at the bottom of the file were still using
> the ordinal HTML id, which did not correspond to the href with the
> label.
>
> 2. If the file had a mixture of labeled and anonymous/unlabeled
> footnotes, then the export would break as it would be passing a nil
> value to 'string-to-number'.
>
> Please let me know how to proceed.
Since we are now using labels for the HTML export, I think it makes
sense to optionally use those for the anchor tags as well.
See the attached patch for a possible way of doing this.
As always, you are welcome to make any further changes.
--
Protesilaos Stavrou
https://protesilaos.com
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Provide-option-to-use-footnote-label-as-the-HTML-anc.patch --]
[-- Type: text/x-diff, Size: 2314 bytes --]
From 681db0934e55ae6c2971ccfbfd9de7c0828506c9 Mon Sep 17 00:00:00 2001
Message-Id: <681db0934e55ae6c2971ccfbfd9de7c0828506c9.1714119282.git.info@protesilaos.com>
From: Protesilaos Stavrou <info@protesilaos.com>
Date: Fri, 26 Apr 2024 11:14:28 +0300
Subject: [PATCH] Provide option to use footnote label as the HTML anchor text
* lisp/ox-html.el (org-html-footnote-use-label-for-anchor-text):
Define new user option.
(org-html-footnote-section, org-html-footnote-reference): Use the new
option.
---
lisp/ox-html.el | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 0237e61..804a464 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -699,6 +699,17 @@ (defcustom org-html-footnote-separator "<sup>, </sup>"
:group 'org-export-html
:type 'string)
+(defcustom org-html-footnote-use-label-for-anchor-text nil
+ "When non-nil, use the footnote label as the anchor text.
+When nil, use the number of the footnote as the anchor text.
+
+- For footnotes, this is the format: [fn:LABEL].
+- For inline footnotes, it is this: [fn:LABEL: Some text]."
+ :group 'org-export-html
+ :version "30.1"
+ :package-version '(Org . "9.7")
+ :type 'boolean)
+
;;;; Headline
(defcustom org-html-toplevel-hlevel 2
@@ -1900,7 +1911,9 @@ (defun org-html-footnote-section (info)
(if label
(format "fn.%s" label)
(format "fn.%d" n))
- n
+ (if (and org-html-footnote-use-label-for-anchor-text label)
+ label
+ n)
(format " class=\"footnum\" href=\"#fnr.%s\" role=\"doc-backlink\"" (or label n))
info))
(contents (org-trim (org-export-data def info))))
@@ -2768,7 +2781,11 @@ (defun org-html-footnote-reference (footnote-reference _contents info)
(format
(plist-get info :html-footnote-format)
(org-html--anchor
- id n (format " class=\"footref\" href=\"#fn.%s\" role=\"doc-backlink\"" (or label n)) info)))))
+ id
+ (if (and org-html-footnote-use-label-for-anchor-text label)
+ label
+ n)
+ (format " class=\"footref\" href=\"#fn.%s\" role=\"doc-backlink\"" (or label n)) info)))))
;;;; Headline
--
2.39.2
next prev parent reply other threads:[~2024-04-26 8:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a5lgv8qd.fsf@protesilaos.com \
--to=info@protesilaos.com \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).