From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id CNjLEsh+02YLcwEA62LTzQ:P1 (envelope-from ) for ; Sat, 31 Aug 2024 20:36:24 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id CNjLEsh+02YLcwEA62LTzQ (envelope-from ) for ; Sat, 31 Aug 2024 22:36:24 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=adamkovic.org header.s=fm2 header.b=dlhJ3rau; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm1 header.b=FMRnzyRN; 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=fail reason="SPF not aligned (relaxed)" header.from=adamkovic.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1725136584; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=U89GaMRN/qNi0n+5U5Z98EVwpIqCx81Pvkqo4AZYKRk=; b=lFZ1Wm/UA0FQuSCGMGcQdU+uww3kAmp917LHgaGzILyXVq2tR6KueWHSzICvNeBQGy4HFM C1Dmr9+V2vxtvsWFVtnp+dBKToRyHxr2Rs3597HowWlofkqBYrWfMvlHmpJ+DKrn7AAd+f K6GAMwjTmAVQzfg4pxPAB3Tse3eFQN6oJmDCRkF2PsXT8Geq05zfv3MNaslj99rBDoO1IL kvxgxGmFskLu/M6kAr16K4govUPcpob34+c5Gp6Eq0l9zorUu7YR1D40rq3qNlE2JOVRjY jyEIS4QTI7TAgA0hnFVdZk0YrNffgjfm37H4NHYTv6keMYQgeYWDpnbYXehqQw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=adamkovic.org header.s=fm2 header.b=dlhJ3rau; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm1 header.b=FMRnzyRN; 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=fail reason="SPF not aligned (relaxed)" header.from=adamkovic.org (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1725136584; a=rsa-sha256; cv=none; b=OHCyWtouxH7mlSHm9E+MQCph0pv3IADCcKOhzDp/ZJGqC5Zy5LXAeM/fLmYgRrMcU/+zeS odoDYT8zcdnqjwM3UxgMDHwwGB7yOU9SWZMDqAQ3mbuFWIzhBhUF5838JNhRsrIwD5DvXg eqARYsbDmPsoTGZ5g0sj9XJG+rQimArME4MHSgirNNmbOWgRSXz7MoG6gnIFFf3IzZ9Igg twiQ6PlHqgD6ReuMsN6b3EcJqXV0h2a39Zn7UZ3VdJxfwHqePUWN8dFKF5KGpPgYwYj4RK ZpXOTvLcsaRYH5xORe/4wm2PbTFVSP/iJGjikTh6KDtL98zbgc1hdVcfRupqow== 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 178457122D for ; Sat, 31 Aug 2024 22:36:23 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1skUov-0003gt-4q; Sat, 31 Aug 2024 16:35:41 -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 1skUop-0003gI-Dm for emacs-orgmode@gnu.org; Sat, 31 Aug 2024 16:35:35 -0400 Received: from fhigh1-smtp.messagingengine.com ([103.168.172.152]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1skUon-0005mb-NX for emacs-orgmode@gnu.org; Sat, 31 Aug 2024 16:35:35 -0400 Received: from phl-compute-08.internal (phl-compute-08.nyi.internal [10.202.2.48]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 6F2CA11400C6; Sat, 31 Aug 2024 16:35:32 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Sat, 31 Aug 2024 16:35:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adamkovic.org; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to; s=fm2; t=1725136532; x=1725222932; bh=A8mizsKSk6 DR00Lh8TuWX3DwXdljqIghjTQtQN+f2Uw=; b=dlhJ3rauuk4x+j0y80aNBaUORq ERZy+263IQ0idbKAzWQ/85XOPZctd+vFs1mui9I1NGvfXV/vZ/R3ETgcAGDTENzc lK01jvqLJsOlzFCzjffT+omjdL3ok9Oe37s7+LySS/gLzO2gJiCB73m3JCuO3PN4 XEZofDL6YpJgMH3muBtPZhFYcl/BxXrit4GSn5s8vD1juOpR2roA2kOti/gYCkPJ uQ/xLbllgyYbrR9dkP1mxfFdD/8o7UJUZSzGIb2WAgeYlFL/7oFzAs0StIJ7AAmR RzqNXpRSNQ6ii/72EMcuQhxK/NeX9g/keemq++vH/P6gL71LDgROCyB7JZrA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1725136532; x=1725222932; bh=A8mizsKSk6DR00Lh8TuWX3DwXdlj qIghjTQtQN+f2Uw=; b=FMRnzyRN9zClfRw+MFFksjCBeTV80bgtwaS4iRMIoYpT eXwGVdnOYoKfT0gXKJd9Fbyam5BHE8W0WHpMc0whbcqE4/RS05L4CBeEIDHS8Y8p EbDCw3Cv1N5WZjp1JDDCkNc6fJsYtw/tDyTb+fpapklKGvQTzAPemqFUtkI5N/oA 1nmX1DskUpH6NVsmdVPR/FkflH6O8Iksl+WALpC+jarcDo9cKt9uD3kyBzYc98uK gO0G3NKsu2cbp3vb0Mh5SrNelgmeFpHDrbyVEYjSwNYjoulauwROq1VnYHo2ihtA OrWDpeqS1HbMifaTMshc5af7+W7Vj97zTpnKAf+rpA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudefkedgudehtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhephffvve fufffkofgggfestdekredtredtjeenucfhrhhomheptfhuugholhhfucetuggrmhhkohhv ihgtuceorhhuugholhhfsegruggrmhhkohhvihgtrdhorhhgqeenucggtffrrghtthgvrh hnpeeiieffveevkeehtdffgeekieevgfegveekkefhgfetueffkeduffeiieehhfekkeen ucffohhmrghinhepuhhnihhquhgvrdhorhhgpdhplhhishhtrdhorhhgnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhhuugholhhfsegruggr mhhkohhvihgtrdhorhhgpdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuth dprhgtphhtthhopegvmhgrtghsqdhorhhgmhhouggvsehgnhhurdhorhhgpdhrtghpthht oheprhhuugholhhfsegruggrmhhkohhvihgtrdhorhhg X-ME-Proxy: Feedback-ID: i88214938:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 31 Aug 2024 16:35:31 -0400 (EDT) From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= To: emacs-orgmode@gnu.org Cc: Rudolf Adamkovic Subject: [PATCH] ox-texinfo: Support links in headings Date: Sat, 31 Aug 2024 22:35:26 +0200 Message-ID: <20240831203526.31509-1-rudolf@adamkovic.org> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=103.168.172.152; envelope-from=rudolf@adamkovic.org; helo=fhigh1-smtp.messagingengine.com 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_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: 3.92 X-Migadu-Queue-Id: 178457122D X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: 3.92 X-TUID: D1TvgWfhaYcL From: Rudolf Adamkovic * etc/ORG-NEWS (Texinfo exporter now supports links in headings): Announce the new feature. * lisp/ox-texinfo.el: (org-texinfo--format-entries, org-texinfo--get-node, org-texinfo--sanitize-title-reference, org-texinfo--sanitize-title): A 2-step change: (1) Rename `--sanitize-title' to `--sanitize-title-reference' and (2) create a new `--sanitize-title' sanitation function. The new function is less strict in that does not remove links, which should be allowed in sectioning commands, such as `@unnumbered'. The old function remains more strict, which is useful for generating `@node' names, for example. * testing/lisp/test-ox-texinfo.el: (test-ox-texinfo/headings-with-links): Test the new functionality to avoid regressions in the future. --- etc/ORG-NEWS | 6 ++++++ lisp/ox-texinfo.el | 17 +++++++++++++++-- testing/lisp/test-ox-texinfo.el | 28 ++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 392788055..a9357aa28 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -223,6 +223,12 @@ This way, attachments will remain accessible when opening symlinked Org file. When no attach dir exists, Org mode will still prefer creating it in the "default" directory - where the symlink is located. +*** Texinfo exporter now supports links in headings + +The Texinfo exporter no longer removes links from headings. This +applies to all headings, below and above the =H= and =toc= export +=#+OPTIONS:=. + * Version 9.7 ** Important announcements and breaking changes diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index 6adee9fca..d710b892d 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -524,7 +524,7 @@ node or anchor name is unique." (org-texinfo--sanitize-node (pcase (org-element-type datum) (`headline - (org-texinfo--sanitize-title + (org-texinfo--sanitize-title-reference (org-export-get-alt-title datum info) info)) (`radio-target (org-export-data (org-element-contents datum) info)) @@ -569,6 +569,19 @@ periods, commas and colons." (defun org-texinfo--sanitize-title (title info) "Make TITLE suitable as a section name. TITLE is a string or a secondary string. INFO is the current +export state, as a plist." + (org-export-data-with-backend + title + (org-export-create-backend + :parent 'texinfo + :transcoders `((footnote-reference . ,#'ignore) + (radio-target . ,(lambda (_r c _) c)) + (target . ,#'ignore))) + info)) + +(defun org-texinfo--sanitize-title-reference (title info) + "Make TITLE suitable as a section reference. +TITLE is a string or a secondary string. INFO is the current export state, as a plist." (org-export-data-with-backend title (org-export-toc-entry-backend 'texinfo) info)) @@ -1468,7 +1481,7 @@ a plist containing contextual information." ;; name. Remove them. (replace-regexp-in-string "[ \t]*:+" "" - (org-texinfo--sanitize-title + (org-texinfo--sanitize-title-reference (org-export-get-alt-title h info) info))) (node (org-texinfo--get-node h info)) (entry (concat "* " title ":" diff --git a/testing/lisp/test-ox-texinfo.el b/testing/lisp/test-ox-texinfo.el index b16a344e7..917c7f1cd 100644 --- a/testing/lisp/test-ox-texinfo.el +++ b/testing/lisp/test-ox-texinfo.el @@ -345,5 +345,33 @@ body (should-not (org-element-contents section)) (should (eq first-heading (org-element-parent section))))))) + +;;; Headings with links + +(ert-deftest test-ox-texinfo/headings-with-links () + "Test node and chapter names." + (should + (org-test-with-temp-text + (string-join + (list "* Heading 1" + " ...." + "* Heading 2 ([[* Heading 1][Heading 1]])" + " ....") + "\n") + (let ((export-buffer "*Test Texinfo Export*") + (org-export-show-temporary-export-buffer nil)) + (org-export-to-buffer 'texinfo export-buffer + nil nil nil nil nil + #'texinfo-mode) + (with-current-buffer export-buffer + (goto-char (point-min)) + (and + (re-search-forward "^* Heading 1::$") + (re-search-forward "^* Heading 2 (Heading 1)::$") + (re-search-forward "^@node Heading 1$") + (re-search-forward "^@chapter Heading 1$") + (re-search-forward "^@node Heading 2 (Heading 1)$") + (re-search-forward "^@chapter Heading 2 (@ref{Heading 1})$"))))))) + (provide 'test-ox-texinfo) ;;; test-ox-texinfo.el end here -- 2.46.0