Function: shr-tag-a

shr-tag-a is a byte-compiled function defined in shr.el.gz.

Signature

(shr-tag-a DOM)

Source Code

;; Defined in /usr/src/emacs/lisp/net/shr.el.gz
(defun shr-tag-a (dom)
  (let ((url (dom-attr dom 'href))
        (title (dom-attr dom 'title))
	(start (point))
	shr-start)
    (shr-generic dom)
    (when-let* ((id (and (not (dom-attr dom 'id)) ; Handled by `shr-descend'.
                         (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)
                  (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)
                               (textsec-suspicious-p
                                (cons (shr-expand-url url)
                                      (buffer-substring (or shr-start start)
                                                        (point)))
                                'link))))
        (add-text-properties (or shr-start start) (point)
                             (list 'face '(shr-link textsec-suspicious)))
        (insert (propertize "⚠️" 'help-echo warning))))))