+(defun eww-update-header-line-format ()
+ (if eww-header-line-format
+ (setq header-line-format (format-spec eww-header-line-format
+ `((?u . ,eww-current-url)
+ (?t . ,eww-current-title))))
+ (setq header-line-format nil)))
+
+(defun eww-tag-title (cont)
+ (setq eww-current-title "")
+ (dolist (sub cont)
+ (when (eq (car sub) 'text)
+ (setq eww-current-title (concat eww-current-title (cdr sub)))))
+ (eww-update-header-line-format))
+
+(defun eww-tag-body (cont)
+ (let* ((start (point))
+ (fgcolor (cdr (or (assq :fgcolor cont)
+ (assq :text cont))))
+ (bgcolor (cdr (assq :bgcolor cont)))
+ (shr-stylesheet (list (cons 'color fgcolor)
+ (cons 'background-color bgcolor))))
+ (shr-generic cont)
+ (eww-colorize-region start (point) fgcolor bgcolor)))
+
+(defun eww-colorize-region (start end fg &optional bg)
+ (when (or fg bg)
+ (let ((new-colors (shr-color-check fg bg)))
+ (when new-colors
+ (when fg
+ (add-face-text-property start end
+ (list :foreground (cadr new-colors))))
+ (when bg
+ (add-face-text-property start end
+ (list :background (car new-colors))))))))
+