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.
>From 545b71606609a76be78ddff8d5fe36259a3d8353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <salu...@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
-- "Be especially critical of any statement following the word 'obviously.'" -- Anna Pell Wheeler, 1883-1966 Rudolf Adamkovič <salu...@me.com> [he/him] Studenohorská 25 84103 Bratislava Slovakia