From: "Rudolf Adamkovič" <salutis@me.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Make broken link markers customizable
Date: Thu, 01 Dec 2022 01:15:38 +0100 [thread overview]
Message-ID: <m2wn7cou6t.fsf@me.com> (raw)
[-- 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
next reply other threads:[~2022-12-01 0:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-01 0:15 Rudolf Adamkovič [this message]
2022-12-12 12:52 ` [PATCH] Make broken link markers customizable Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2wn7cou6t.fsf@me.com \
--to=salutis@me.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).