From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id WJhMHYupNGYyXAAA62LTzQ:P1 (envelope-from ) for ; Fri, 03 May 2024 11:08:27 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id WJhMHYupNGYyXAAA62LTzQ (envelope-from ) for ; Fri, 03 May 2024 11:08:27 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=protesilaos.com header.s=gm1 header.b=IEO+56w2; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1714727307; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=72yuVca6DsOZtXYy8IknwIzrXIoIj9tPUXU7cn38VzM=; b=LX4vi3u/bCS+6gMDGmdAf+QEgJD2nxnNEirim9jnFb/ffn/PSR0kWOsr5pjR0+dZyVjqrD kaN30tdgvCTNMY2oxc+Txfpc7YzRoNIXkpQw1ni+Bj8V/DV4GQdlC/TmLIKVM1a6Sr4LFN WAyZGGZGwnYROZooQNoCWegKBPaR7/z2lxpgffvwSMOLxPK/QqewfxqwVl9yGsjgktAumb j5K+TU8ihhamJKHEtlk25heKDLNyqShkEOhpp+fXZQGsfN94Xs/MpRDAHkMz6W013lOD0/ f9KQiwAL30ELINH5Mxqtcpq3JvgiZnQh0NcwNwzYkI5h5XTlo9Ohndxzm3sckA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1714727307; a=rsa-sha256; cv=none; b=fFcVKERoUS/J9228tbMtocUzxE7g6fpSRtJ2xKzFbxZSg2MSxz8UDDXXiW9LmBPL4hxmzg ThtND/JtnzAb/rY2mlQxMkuxu0Q14idTDH2H3+dDCFf0QhVAYWiG8JidM3UpU9s/tDtygv RaoPv4J/Sb1biQvpowy72uKzL8czuYUZMYGH2+q7ARDKqu2IHgfFbyOV6XNYHzPjpbW8Fq YsjVgQmFB7L5mQD3yZY+eyroLRcf5OYC/bI7ZQ1EQAs/DxJLSbwJGU6NXimKOqeO4WW/vt EJsMRkT9cGpXEM77m0TnKcb5KGWMIy6t40aylNljHzJGkNvDh5EHdz1p6DjTow== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=protesilaos.com header.s=gm1 header.b=IEO+56w2; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E04E04420 for ; Fri, 03 May 2024 11:08:26 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s2ot7-00079y-2h; Fri, 03 May 2024 05:07:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2ot4-00079J-Ic for emacs-orgmode@gnu.org; Fri, 03 May 2024 05:07:26 -0400 Received: from relay4-d.mail.gandi.net ([2001:4b98:dc4:8::224]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2ot1-0001nq-ND for emacs-orgmode@gnu.org; Fri, 03 May 2024 05:07:26 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 1A3A0E000B; Fri, 3 May 2024 09:07:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protesilaos.com; s=gm1; t=1714727240; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=72yuVca6DsOZtXYy8IknwIzrXIoIj9tPUXU7cn38VzM=; b=IEO+56w2ptF7KwbtIJunW6/ZOKSKAkF1kgrnsvugb53dCCjnk4d0GhaUFwN6BddcofB0xF stVJJleUFNG8/KH87oTNhylLkVBQoiPcq2M5zfqBI4hjdXMcf87JaXwZEZOPzK4wAV/Tgl Uv8TYO7hrwotbaKVx7Cy65Hur960eObuksVk7LKlih/+dya4tzGXcAC9Ck7wO9229m6vr6 /m/ZZRyQv+abfdm/w53EalPmmU5lUM2le2CzYqLosDWvgt5ejQfVgYwowkTCBDhqwkMIqU bnqVMcovCziyW37ww7YpIUzt+44AF8H2kiVMQvxFNb1wfkdNlHcce/dznZzDZw== From: Protesilaos Stavrou To: Ihor Radchenko 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/)] In-Reply-To: <875xw1lqm1.fsf@localhost> References: <877chcyz36.fsf@protesilaos.com> <87o7anop4i.fsf@localhost> <87y19lfzwv.fsf@protesilaos.com> <875xwpe1c5.fsf@localhost> <875xwngiwx.fsf@protesilaos.com> <871q79cqgf.fsf@localhost> <87cyqcv9q1.fsf@protesilaos.com> <87a5lgv8qd.fsf@protesilaos.com> <875xw1lqm1.fsf@localhost> Date: Fri, 03 May 2024 12:07:19 +0300 Message-ID: <87bk5nclh4.fsf@protesilaos.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-GND-Sasl: info@protesilaos.com Received-SPF: none client-ip=2001:4b98:dc4:8::224; envelope-from=info@protesilaos.com; helo=relay4-d.mail.gandi.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -6.43 X-Spam-Score: -6.43 X-Migadu-Queue-Id: E04E04420 X-Migadu-Scanner: mx11.migadu.com X-TUID: YpUHdqAYUltW --=-=-= Content-Type: text/plain > From: Ihor Radchenko > Date: Sun, 28 Apr 2024 10:37:58 +0000 > > Protesilaos Stavrou writes: > >> 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. > > We can indeed add such option, but is it of any practical use? > Do you have examples of workflows when such new option will be useful? An important purpose of using labels is sustainability. If the document changes, the labels remain (as would CUSTOM_ID). The problem when numbers are used in the anchor text is that if others want to make a reference to the footnote (cite it), they will use what they see (not the ID, which appears in the source only). And if the document changes, their references will be broken. Now, the problem with labels is that their are not visually appealing, especially the longer they get. Another approach is to have a string for the anchor text of the footnote references. Something like "[^]" with a hover/tooltip effect, which shows the full label. [ Of course, the hover/tooltip text can be further enhanced with CSS and JavaScript, but we are keeping it simple for now. Though I think that would ultimately be the best user experience. ] For a proof of concept, see the attached patch, which expands on the previous proposal. While clicking around the footnotes, I noticed that we can also improve the user experience by adding a CSS ":focus" state so that it is easier to spot where we are after following an internal link. I can send this as a separate patch/thread. -- Protesilaos Stavrou https://protesilaos.com --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-option-on-how-to-format-of-HTML-footnote-anchor-.patch >From c6c0aebec12ee19da6ebf7daa972af5b23119358 Mon Sep 17 00:00:00 2001 Message-Id: From: Protesilaos Stavrou Date: Fri, 3 May 2024 11:44:34 +0300 Subject: [PATCH] Add option on how to format of HTML footnote anchor text * lisp/ox-html.el (org-html-footnote-anchor-text): Define new user option. (org-html-footnote-section): Use the new option for the footnote definitions. (org-html-footnote-reference): Use the new option for the footnote references. --- lisp/ox-html.el | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index b35a31865..bbad21a7b 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -766,6 +766,25 @@ (defcustom org-html-prefer-user-labels nil :type 'boolean :safe #'booleanp) +(defcustom org-html-footnote-anchor-text nil + "Choose how to format HTML footnotes. + +When the value is nil, automatically number footnotes and use the number +for the anchor text in both references and definitions. + +When the value is non-nil, use the footnote label as the anchor text for +both the references and definitions. + +When the value is a string, use it for the anchor text of references. +For the anchor text of definitions use either the label, if present, or +an automatically assigned number." + :group 'org-export-html + :version "30.1" + :package-version '(Org . "9.7") + :type '(choice (const :tag "Do not show labels in HTML anchor text; use numbers" nil) + (const :tag "Use labels in HTML anchor text for both references and definitions" t) + (string :tag "Use custom string for HTML anchor text for references and labels for definitions"))) + ;;;; Inlinetasks (defcustom org-html-format-inlinetask-function @@ -1898,7 +1917,12 @@ (defun org-html-footnote-section (info) #'identity nil t))) (anchor (org-html--anchor (format "fn.%s" (or label n)) - n + (cond + ((and org-html-footnote-anchor-text label) + label) + ((and org-html-footnote-anchor-text (null label)) + (user-error "All footnotes must have labels for `org-html-footnote-anchor-text' to work")) + (t n)) (format " class=\"footnum\" href=\"#fnr.%s\" role=\"doc-backlink\"" (or label n)) info)) (contents (org-trim (org-export-data def info)))) @@ -2757,6 +2781,7 @@ (defun org-html-footnote-reference (footnote-reference _contents info) (equal label (number-to-string (string-to-number label)))) nil label)) + (anchor-is-string (stringp org-html-footnote-anchor-text)) (id (format "fnr.%s%s" (or label n) (if (org-export-footnote-first-reference-p @@ -2774,7 +2799,21 @@ (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 + (cond + ((string-blank-p org-html-footnote-anchor-text) + (user-error "`org-html-footnote-anchor-text' cannot be an empty string")) + (anchor-is-string + org-html-footnote-anchor-text) + ((and org-html-footnote-anchor-text label) + label) + ((and org-html-footnote-anchor-text (null label)) + (user-error "All footnotes must have labels for `org-html-footnote-anchor-text' to work")) + (t n)) + (if (and anchor-is-string label) + (format " class=\"footref\" href=\"#fn.%s\" title=\"%s\" role=\"doc-backlink\"" label label) + (format " class=\"footref\" href=\"#fn.%s\" role=\"doc-backlink\"" (or label n))) + info))))) ;;;; Headline -- 2.39.2 --=-=-=--