From 45ebbc0301c8514a5f3215f45981c787cb26f915 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 24 Dec 2015 17:34:31 +0100 Subject: [PATCH] Allow overriding shr functions from eww * eww.el (eww-display-html): Allow overriding elements in `shr-external-rendering-functions'. --- lisp/net/eww.el | 16 +++++++++------- lisp/net/shr.el | 9 ++++++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 5748e88bbca..2224b2e74e7 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -411,13 +411,15 @@ Currently this means either text/html or application/xhtml+xml." (inhibit-modification-hooks t) (shr-target-id (url-target (url-generic-parse-url url))) (shr-external-rendering-functions - '((title . eww-tag-title) - (form . eww-tag-form) - (input . eww-tag-input) - (textarea . eww-tag-textarea) - (select . eww-tag-select) - (link . eww-tag-link) - (a . eww-tag-a)))) + (append + shr-external-rendering-functions + '((title . eww-tag-title) + (form . eww-tag-form) + (input . eww-tag-input) + (textarea . eww-tag-textarea) + (select . eww-tag-select) + (link . eww-tag-link) + (a . eww-tag-a))))) (erase-buffer) (shr-insert-document document) (cond diff --git a/lisp/net/shr.el b/lisp/net/shr.el index d51b8c73d10..23899521140 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -135,6 +135,14 @@ cid: URL as the argument.") (defvar shr-inhibit-images nil "If non-nil, inhibit loading images.") +(defvar shr-external-rendering-functions nil + "Alist of tag/function pairs used to alter how shr renders certain tags. +For instance, eww uses this to alter rendering of title, forms +and other things: +((title . eww-tag-title) + (form . eww-tag-form) + ...)") + ;;; Internal variables. (defvar shr-folding-mode nil) @@ -150,7 +158,6 @@ cid: URL as the argument.") (defvar shr-depth 0) (defvar shr-warning nil) (defvar shr-ignore-cache nil) -(defvar shr-external-rendering-functions nil) (defvar shr-target-id nil) (defvar shr-table-separator-length 1) (defvar shr-table-separator-pixel-width 0) -- 2.39.2