summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/eww.el1
-rw-r--r--lisp/net/shr.el9
2 files changed, 9 insertions, 1 deletions
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 35e5bdd7342..34e74f8ffaa 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1180,6 +1180,7 @@ the like."
'((url . eww--url-at-point))))
(setq-local bookmark-make-record-function #'eww-bookmark-make-record)
(buffer-disable-undo)
+ (setq-local shr-url-transformer #'eww--transform-url)
(setq buffer-read-only t))
(defun eww--url-at-point ()
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index a06978d9ce0..54ce9b1a41c 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -295,6 +295,11 @@ and other things:
(make-composed-keymap shr-map image-map)
shr-map))
+(defvar shr-url-transformer #'identity
+ "Function to transform URLs.
+It's called with the URL as the parameter, and should return the
+ URL to use.")
+
;; Public functions and commands.
(declare-function libxml-parse-html-region "xml.c"
(start end &optional base-url discard-comments))
@@ -1489,7 +1494,9 @@ ones, in case fg and bg are nil."
(dom-attr dom 'name)))) ; Obsolete since HTML5.
(push (cons id (set-marker (make-marker) start)) shr--link-targets))
(when url
- (shr-urlify (or shr-start start) (shr-expand-url url) title)
+ (shr-urlify (or shr-start start)
+ (funcall shr-url-transformer (shr-expand-url url))
+ title)
;; Check whether the URL is suspicious.
(when-let ((warning (or (textsec-suspicious-p
(shr-expand-url url) 'url)