emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Make broken link markers customizable
@ 2022-12-01  0:15 Rudolf Adamkovič
  2022-12-12 12:52 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Rudolf Adamkovič @ 2022-12-01  0:15 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 667 bytes --]

Hello there!

Org provides no good way to ignore broken links when exporting subtrees
with lots of links.  With `org-export-with-broken-links' set to `nil',
the exporter aborts.  When set to `t', the exporter removes the linked
words altogether, breaking the sentences.  Lastly, when set to `mark',
the sentences become unreadable due to the million [BROKEN LINK: ...]
fragments everywhere.

What do you folks think about the WIP patch below?  It allows the user
to customize the broken link marker the Org exporter will use.  A user
like me, one who works in a large Org file and often exports only its
parts, can use a more gentle marker or even no marker at all.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-export-Make-broken-link-markers-customizable-WIP.patch --]
[-- Type: text/x-patch, Size: 2207 bytes --]

From 545b71606609a76be78ddff8d5fe36259a3d8353 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <salutis@me.com>
Date: Thu, 1 Dec 2022 00:59:39 +0100
Subject: [PATCH] org-export: Make broken link markers customizable [WIP]

---
 lisp/ox.el | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index 5c0a8f242..5f653698c 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -856,13 +856,9 @@ is nil.  You can also allow them through local buffer variables."
 
 When this variable is non-nil, broken links are ignored, without
 stopping the export process.  If it is set to `mark', broken
-links are marked as such in the output, with a string like
+links are marked with `org-export-broken-link-marker'.
 
-  [BROKEN LINK: path]
-
-where PATH is the un-resolvable reference.
-
-This option can also be set with the OPTIONS keyword, e.g.,
+This variable can also be set with the OPTIONS keyword, e.g.,
 \"broken-links:mark\"."
   :group 'org-export-general
   :version "26.1"
@@ -872,6 +868,18 @@ This option can also be set with the OPTIONS keyword, e.g.,
 	  (const :tag "Mark broken links in output" mark)
 	  (const :tag "Raise an error" nil)))
 
+(defcustom org-export-broken-link-marker "[BROKEN LINK: %s]"
+  "The string used to mark broken links.
+
+This variable applies only when `org-export-with-broken-links' is
+set to `mark'.  If the value contains the %-sequence `%s', the
+exporter will replace it with the broken reference which it
+cannot resolve."
+  :group 'org-export-general
+  :package-version '(Org . "9.7")
+  :type 'string
+  :safe #'stringp)
+
 (defcustom org-export-snippet-translation-alist nil
   "Alist between export snippets back-ends and exporter back-ends.
 
@@ -1893,7 +1901,8 @@ Return a string."
 		(pcase (plist-get info :with-broken-links)
 		  (`nil (user-error "Unable to resolve link: %S" (nth 1 err)))
 		  (`mark (org-export-data
-			  (format "[BROKEN LINK: %s]" (nth 1 err)) info))
+			  (format org-export-broken-link-marker (nth 1 err))
+                          info))
 		  (_ nil))))))
 	(let* ((type (org-element-type data))
 	       (parent (org-export-get-parent data))
-- 
2.38.1


[-- Attachment #3: Type: text/plain, Size: 207 bytes --]

--
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-12 12:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-01  0:15 [PATCH] Make broken link markers customizable Rudolf Adamkovič
2022-12-12 12:52 ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).