(defvar shr-kinsoku-shorten nil)
(defvar shr-table-depth 0)
(defvar shr-stylesheet nil)
+(defvar shr-base nil)
(defvar shr-map
(let ((map (make-sparse-keymap)))
(setq shr-content-cache nil)
(let ((shr-state nil)
(shr-start nil)
+ (shr-base nil)
(shr-width (or shr-width (window-width))))
(shr-descend (shr-transform-dom dom))))
(forward-char 1))))
(not failed)))
+(defun shr-expand-url (url)
+ (cond
+ ;; Absolute URL.
+ ((or (string-match "\\`[a-z]*:" url)
+ (not shr-base))
+ url)
+ ((and (not (string-match "/\\'" shr-base))
+ (not (string-match "\\`" url)))
+ (concat shr-base "/" url))
+ (t
+ (concat shr-base url))))
+
(defun shr-ensure-newline ()
(unless (zerop (current-column))
(insert "\n")))
plist)))))
plist)))
+(defun shr-tag-base (cont)
+ (setq shr-base (cdr (assq :href cont))))
+
(defun shr-tag-a (cont)
(let ((url (cdr (assq :href cont)))
(title (cdr (assq :title cont)))
(start (point))
shr-start)
(shr-generic cont)
- (shr-urlify (or shr-start start) url title)))
+ (shr-urlify (or shr-start start) (shr-expand-url url) title)))
(defun shr-tag-object (cont)
(let ((start (point))
(setq url (or url (cdr (assq :value (cdr elem)))))))
(when url
(shr-insert " [multimedia] ")
- (shr-urlify start url))
+ (shr-urlify start (shr-expand-url url)))
(shr-generic cont)))
(defun shr-tag-video (cont)
(url (cdr (assq :src cont)))
(start (point)))
(shr-tag-img nil image)
- (shr-urlify start url)))
+ (shr-urlify start (shr-expand-url url))))
(defun shr-tag-img (cont &optional url)
(when (or url
(not (eq shr-state 'image)))
(insert "\n"))
(let ((alt (cdr (assq :alt cont)))
- (url (or url (cdr (assq :src cont)))))
+ (url (shr-expand-url (or url (cdr (assq :src cont))))))
(let ((start (point-marker)))
(when (zerop (length alt))
(setq alt "*"))