I have attached a proposal for a bugfix for this issue:
Currently, when self-linking headlines are created, the pre-processed
text may already contain html links generated through radio targets
which results in the creation of a link within a link. By using the
method `org-html--format-toc-headline' instead of `format', these
links will be stripped out.
On 8/11/2026 10:16 PM, Michael Korat wrote:
Hi,
is it possible to configure radio targets/radio links in a way that
text in headlines is not considered during the identification of radio
links?
I have the following use case:
I am writing a document in org-mode which I am exporting to HTML. I am
using radio-targets to write a glossary and the
org-html-self-link-headlines option, so that I can easily link to
individual chapters on the resulting web page. Unfortunately,
self-links and radio-links clash, and headlines that contain a keyword
from my radio-targets will use the radio-links instead of the self-links.
Kind regards,
Michael
From c8d0dc92ffe7e753d88946c79158d0a68cb1993f Mon Sep 17 00:00:00 2001
From: Michael Korat <[email protected]>
Date: Sun, 16 Aug 2026 22:44:20 +0200
Subject: [PATCH] lisp/ox-html.el: Radio links removed from self-linking
headlines
* ox-html.el (org-html--format-toc-headline): Added an optional
parameter to force an output without toc/headline numbering. If the
parameter is set, the numbering part will not be concatenated at the
beginning of the heading string.
(org-html-headline): Use the adapted `org-html--format-toc-headline'
method to create the html link instead of `format'.
Currently, when self-linking headlines are created, the pre-processed
text may already contain html links generated through radio targets
which results in the creation of a link within a link. By using the
method `org-html--format-toc-headline' instead of `format', these
links will be stripped out.
Reported-by: "Michael Korat" <[email protected]>
Link:
https://list.orgmode.org/[email protected]/
TINYCHANGE
---
lisp/ox-html.el | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 5d6b31002..e5c4c6eaf 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2617,9 +2617,10 @@ initial nesting level."
toc-entries "")
(org-html--make-string (- prev-level start-level) "</li>\n</ul>\n"))))
-(defun org-html--format-toc-headline (headline info)
+(defun org-html--format-toc-headline (headline info &optional force-unnumbered)
"Return an appropriate table of contents entry for HEADLINE.
-INFO is a plist used as a communication channel."
+INFO is a plist used as a communication channel.
+FORCE-UNNUMBERED will always generate a headline without prefixed numbering"
(let* ((headline-number (org-export-get-headline-number headline info))
(todo (and (plist-get info :with-todo-keywords)
(let ((todo (org-element-property :todo-keyword headline)))
@@ -2644,6 +2645,7 @@ INFO is a plist used as a communication channel."
(concat
(and (not (org-export-low-level-p headline info))
(org-export-numbered-headline-p headline info)
+ (not force-unnumbered)
(concat (mapconcat #'number-to-string headline-number ".")
". "))
(apply (plist-get info :html-format-headline-function)
@@ -2909,7 +2911,7 @@ holding contextual information."
(id (org-html--reference headline info))
(formatted-text
(if (plist-get info :html-self-link-headlines)
- (format "<a href=\"#%s\">%s</a>" id full-text)
+ (org-html--format-toc-headline headline info t)
full-text)))
(if (org-export-low-level-p headline info)
;; This is a deep sub-tree: export it as a list item.
--
2.55.0