From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id 4E8+FESQGmaWVQEA62LTzQ:P1 (envelope-from ) for ; Sat, 13 Apr 2024 16:01:40 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id 4E8+FESQGmaWVQEA62LTzQ (envelope-from ) for ; Sat, 13 Apr 2024 16:01:40 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=OEB5MbUX; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1713016900; 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=/shtHzCtxooa6YM2I3i692CP1NYsQbs78TLxTAM6nUI=; b=sAOS7qPbdLeasoewGsnUi0j1f8G4kvmx33j6dC/nxmfKZEF+cdWCc3R++GA2hBeedScG5O AfIo3v+gRGFhdmX2eHjwB7rQSG0iP/zZj1aDiV/PqFPiz80CmCFGcdWDsE1OkwMQgauMHc kq0mcv+EUYPHkh62KC3fLL69CSJ4JpNfcYPvia0MZyJwo3RYlOwB5ulM73ZuJDwP2saPkj d/cMRV5CO5GsuYH6zwTegerUd2S9T6UK9cAz//aOs48oi5IosSiF5TgtMpepC4eEFf5Ll3 oXoZgwd7ii6LZ+rI94XWe67SPr8q6dU8+ZNr23NZi6p0yDOfEteorJPlahpJEA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1713016900; a=rsa-sha256; cv=none; b=EdezZ3/UrElS1mxfj3pA+VX38u8hlXlIj0YtySHvONtgDIBbXWYM0dlNiYFpO7txDKqWMT yY3m0bv4T/bfrpTverbIoAtf2PbVFsyLPJthCUZeza23zqK6lMg0l8ljj47SE9YFWAL+bg mzor8fjHjY+5klVGjGEMJVWTjvds8p/J64s41oVXDmkoT7KDTfCIPyrnglPaB0q1WoJNCo 8A3wnkJcD0aLb/8PdZP5qySynrKcKPfNjhcqw2IK0etBgAb/O9Rj1vLVw/li8ntXzOEOKI x4p9LxQiJMFcTPD4uB62LVNtZOtyDppARN9gYY96oc5cgxig0/PgAZQXOqeqUA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=OEB5MbUX; 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"; dmarc=pass (policy=none) header.from=posteo.net 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 E3C7D225D0 for ; Sat, 13 Apr 2024 16:01:39 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rvdw0-0001Dv-Ps; Sat, 13 Apr 2024 10:00:51 -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 1rvdvf-0001A0-2K for emacs-orgmode@gnu.org; Sat, 13 Apr 2024 10:00:27 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rvdva-0006DF-P6 for emacs-orgmode@gnu.org; Sat, 13 Apr 2024 10:00:25 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id A23CC240027 for ; Sat, 13 Apr 2024 16:00:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1713016819; bh=v00cmxR6goSaTak5gDMEYJcYQPuGMnWXW8T0nc8Mw64=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=OEB5MbUXhWVtsj2b6WBEFlpEl94ERqldyFXZR5vc3V5zcbqjjRIjDNLsjIBgGUFtB /CIiJfdBUiVjRCEeOybe5hIU4vPWMzd/0qtYEkbPK4OO6Ia+3CcGbcam7xeqKnV7kG Zf3nKSqHFm5rE6mLk9IOhBR3s6/65uPEVhxXbgqY3eg4aWpTMdVUyCB+3OLPNZ2ZJ5 CEEypDJuleLADSwZoRN39JtpbNJEMKjr4Gox3tC5X0nOwf+GQy8G17FFe+dkBXXm7T F2YMlJ9mmPNvDZcU8tW7eFI3F7CwghpGVvBoFvLLa3TN3aQ60eYfoF3SvBQLRc3W8c R04TMhZy13ubw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VGw7601v8z9rxK; Sat, 13 Apr 2024 16:00:17 +0200 (CEST) From: Ihor Radchenko To: Protesilaos Stavrou 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: <875xwngiwx.fsf@protesilaos.com> References: <877chcyz36.fsf@protesilaos.com> <87o7anop4i.fsf@localhost> <87y19lfzwv.fsf@protesilaos.com> <875xwpe1c5.fsf@localhost> <875xwngiwx.fsf@protesilaos.com> Date: Sat, 13 Apr 2024 14:00:48 +0000 Message-ID: <871q79cqgf.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: -7.59 X-Spam-Score: -7.59 X-Migadu-Queue-Id: E3C7D225D0 X-Migadu-Scanner: mx12.migadu.com X-TUID: ETkFqJSqQKZC --=-=-= Content-Type: text/plain Protesilaos Stavrou writes: > With regard to the disambiguation scheme, I am playing around with > various scenaria to see how Org HTML export behaves. Using the > following: > ... > This is test 2 1 > ... > This is test 3 1 > > Notice that the 100 in the ID is not incremented further. I guess this > is something that can be worked on but, again, I think it is separate > from the issue of using the label for the ID and HREF. > > Any thoughts? Duplicate IDs are against HTML spec: https://softwareengineering.stackexchange.com/questions/127178/two-html-elements-with-same-id-attribute-how-bad-is-it-really So, this is a bug. >>> Though I should have clarified my intent earlier: the idea is to use the >>> label as a fixed reference to the footnote, so that the link does not >>> change between exports. This is the same principle as what we do with >>> links to headings that have a CUSTOM_ID. >>> >>> As such, the anchor text can still be the way it is now as an >>> automatically generated number sequence (^1, ^2, etc.), but the HTML >>> "id" and "href" values will be constructed based on the label of the >>> footnote, NOT its number in the sequence. See the attached tentative patch. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ox-html-Use-non-number-footnote-names-as-link-anchor.patch >From 446bfc8c8afb5b2e09d0e0acf7b136b9f0780f5a Mon Sep 17 00:00:00 2001 Message-ID: <446bfc8c8afb5b2e09d0e0acf7b136b9f0780f5a.1713016519.git.yantar92@posteo.net> From: Ihor Radchenko Date: Sat, 13 Apr 2024 16:53:48 +0300 Subject: [PATCH] ox-html: Use non-number footnote names as link anchors * lisp/ox-html.el (org-html-footnote-section): * lisp/ox-html.el (org-html-footnote-reference): When footnote has a non-number name, build link anchors using this name. * etc/ORG-NEWS (=ox-html=: When exporting footnotes with custom non-number names, the names are used as link anchors): Announce the change. Link: https://orgmode.org/list/875xwngiwx.fsf@protesilaos.com --- etc/ORG-NEWS | 8 +++++ lisp/ox-html.el | 77 +++++++++++++++++++++++++++++-------------------- 2 files changed, 53 insertions(+), 32 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index e61bd6988..1b7040815 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -13,6 +13,14 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org. * Version 9.7 (not released yet) ** Important announcements and breaking changes +*** =ox-html=: When exporting footnotes with custom non-number names, the names are used as link anchors + +Previously, link anchors for footnote references and footnote +definitions were based on the footnote number: =fn.1=, =fnr.15=, etc. + +Now, when the footnote has a non-number name, it is used as an anchor: +=fn.name=, =fnr.name=. + *** Underline syntax now takes priority over subscript when both are applicable Previously, Org mode interpreted =(_text_)= as subscript. diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 0471a573b..1262da1aa 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -1873,36 +1873,42 @@ (defun org-html-footnote-section (info) (pcase (org-export-collect-footnote-definitions info) (`nil nil) (definitions + (format + (plist-get info :html-footnotes-section) + (org-html--translate "Footnotes" info) (format - (plist-get info :html-footnotes-section) - (org-html--translate "Footnotes" info) - (format - "\n%s\n" - (mapconcat - (lambda (definition) - (pcase definition - (`(,n ,_ ,def) - ;; `org-export-collect-footnote-definitions' can return - ;; two kinds of footnote definitions: inline and blocks. - ;; Since this should not make any difference in the HTML - ;; output, we wrap the inline definitions within - ;; a "footpara" class paragraph. - (let ((inline? (not (org-element-map def org-element-all-elements - #'identity nil t))) - (anchor (org-html--anchor - (format "fn.%d" n) - n - (format " class=\"footnum\" href=\"#fnr.%d\" role=\"doc-backlink\"" n) - info)) - (contents (org-trim (org-export-data def info)))) - (format "
%s %s
\n" - (format (plist-get info :html-footnote-format) anchor) - (format "
%s
" - (if (not inline?) contents - (format "

%s

" - contents)))))))) - definitions - "\n")))))) + "\n%s\n" + (mapconcat + (lambda (definition) + (pcase definition + (`(,n ,label ,def) + ;; Do not assign number labels as they appear in Org mode + ;; - the footnotes are re-numbered by + ;; `org-export-get-footnote-number'. If the label is not + ;; a number, keep it. + (when (equal label (number-to-string (string-to-number label))) + (setq label nil)) + ;; `org-export-collect-footnote-definitions' can return + ;; two kinds of footnote definitions: inline and blocks. + ;; Since this should not make any difference in the HTML + ;; output, we wrap the inline definitions within + ;; a "footpara" class paragraph. + (let ((inline? (not (org-element-map def org-element-all-elements + #'identity nil t))) + (anchor (org-html--anchor + (format "fn.%d" n) + n + (format " class=\"footnum\" href=\"#fnr.%s\" role=\"doc-backlink\"" (or label n)) + info)) + (contents (org-trim (org-export-data def info)))) + (format "
%s %s
\n" + (format (plist-get info :html-footnote-format) anchor) + (format "
%s
" + (if (not inline?) contents + (format "

%s

" + contents)))))))) + definitions + "\n")))))) ;;; Template @@ -2736,8 +2742,15 @@ (defun org-html-footnote-reference (footnote-reference _contents info) (when (org-element-type-p prev 'footnote-reference) (plist-get info :html-footnote-separator))) (let* ((n (org-export-get-footnote-number footnote-reference info)) - (id (format "fnr.%d%s" - n + (label (org-element-property :label footnote-reference)) + ;; Do not assign number labels as they appear in Org mode - + ;; the footnotes are re-numbered by + ;; `org-export-get-footnote-number'. If the label is not a + ;; number, keep it. + (label (if (equal label (number-to-string (string-to-number label))) + nil label)) + (id (format "fnr.%s%s" + (or label n) (if (org-export-footnote-first-reference-p footnote-reference info) "" @@ -2745,7 +2758,7 @@ (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.%d\" role=\"doc-backlink\"" n) info))))) + id n (format " class=\"footref\" href=\"#fn.%s\" role=\"doc-backlink\"" (or label n)) info))))) ;;;; Headline -- 2.44.0 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--