From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id mKFQFkZjK2YdUwAAqHPOHw:P1 (envelope-from ) for ; Fri, 26 Apr 2024 10:18:14 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id mKFQFkZjK2YdUwAAqHPOHw (envelope-from ) for ; Fri, 26 Apr 2024 10:18:14 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=protesilaos.com header.s=gm1 header.b=J7n1lY3Y; 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-Seal: i=1; s=key1; d=yhetil.org; t=1714119494; a=rsa-sha256; cv=none; b=VugnKkO2326LUJrlPT/S4jAl4ZUOjZyj0PbtgCbpMjcn/JDgZQ6jjCwm4H2oz8W8rd2GqS 2pUFNjo9mbYH8gsVlceIED3bmirsQLIGsnbO3kBT42ZRYQ/6KBHLeVX9OxQ+DvBroppHxT Eb1SWSb/5F0xO9IX5KlGW6YUdF8BAEXHxtKpKHX5Tn0uyi2DBf8JlRKQ4ykkwLyEjT2Rb7 lQOKJwlCWoFqr4YpICK9x4SlHZNJWp1QQoTBYtGL629c+MX+5QoIpGP12bHv99I+OdyjdQ MY6rvNG7ukQ4WIvK2VmDUiBf3PuO/MzkCJi0eVPqB3sTzWOGBHy/wLH1WPnqCA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=protesilaos.com header.s=gm1 header.b=J7n1lY3Y; 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=1714119494; 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=52khnbhTa5gSgjc1p7Iq2Z6XVcoBMSf6z5160tTea00=; b=ZtVB88KGBS6EGryPPsa/4BSLPynmxQjX3KIxxmdj2SYqa3iGiXVKuHlT81oZ1LtWZgndHK Vcdz3YT/em8nReLpoQy7hcAlTHmwjiHtKQXThwAmwFNIxo6l1+faukARpVXuDozJKOqhXi 0qqIxmlZwNhvVCjHRN9PXkzVpwB9/1i3g71y+W3g7MQie1Up/x4SwEKugEFlPe+ViaLlk6 kemOSSGhioV1K2VDWeHqyTm9V/A5rDLG9zXJlniCBBnIGxAxJ49JlLmERrF/Y1TnCjTDxW 21CJCeHhkW1Xv11v+7oxuREhvtJVb6suwS8oj5Xc/SmInbZ7mGxYFRDNxn+MEQ== 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 985AC76595 for ; Fri, 26 Apr 2024 10:18:13 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s0Glm-0006HJ-Sf; Fri, 26 Apr 2024 04:17:22 -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 1s0Gll-0006Gv-Pb for emacs-orgmode@gnu.org; Fri, 26 Apr 2024 04:17:21 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s0Gli-0004uv-W6 for emacs-orgmode@gnu.org; Fri, 26 Apr 2024 04:17:21 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 12F251BF21E; Fri, 26 Apr 2024 08:17:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protesilaos.com; s=gm1; t=1714119436; 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=52khnbhTa5gSgjc1p7Iq2Z6XVcoBMSf6z5160tTea00=; b=J7n1lY3YBT+0P/Rb79qYjKRo/Musk0Ogmd5J1IJgIb1J1dT+WToULZi0AaqLIgjocHGXyU iYQNQSgthfDMTR75j51Vi/Hl/tGOmJ6zsJ9KKv1YnlhHGijWO2fS5NJnD6vLO/2hik9qbz EMn2VBvb/V7PaJAUYWhBXZT4nVG5g8qcGvNCJdCiV/WwLQBhFIejgL07CzCxmXBarcMU5I GXG96Sb1VjlcgY9TTqqbFPxSKqV4hiiualGMOLIm4fHwQJQIP+BDuTt0e7Y0WzjR+G4U9+ ZMSmuYkYbBFJV2hvdLiUzUX+zcsrCgyaCS6A+vGIHFIK70ZKRvm9LHr8b+/tuQ== 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: <87cyqcv9q1.fsf@protesilaos.com> 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> Date: Fri, 26 Apr 2024 11:17:14 +0300 Message-ID: <87a5lgv8qd.fsf@protesilaos.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-GND-Sasl: info@protesilaos.com Received-SPF: none client-ip=217.70.183.201; envelope-from=info@protesilaos.com; helo=relay8-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, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-Spam-Score: -9.39 X-Migadu-Queue-Id: 985AC76595 X-Migadu-Spam-Score: -9.39 X-Migadu-Scanner: mx10.migadu.com X-TUID: 89P8WmZs90eK --=-=-= Content-Type: text/plain Hello again! A follow-up on the patches below: > From: Protesilaos Stavrou > 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Provide-option-to-use-footnote-label-as-the-HTML-anc.patch >From 681db0934e55ae6c2971ccfbfd9de7c0828506c9 Mon Sep 17 00:00:00 2001 Message-Id: <681db0934e55ae6c2971ccfbfd9de7c0828506c9.1714119282.git.info@protesilaos.com> From: Protesilaos Stavrou 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 ", " :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 --=-=-=--