(eww-readable): Decode the saved text correctly.
(eww-readable): Save the history before displaying so that we can
go back to the non-readable version.
+ (eww-display-html): Don't try to decode the text if we've been
+ passed in a pre-parsed DOM.
2014-11-02 Lars Magne Ingebrigtsen <larsi@gnus.org>
(defun eww-display-html (charset url &optional document point)
(or (fboundp 'libxml-parse-html-region)
(error "This function requires Emacs to be compiled with libxml2"))
- (unless (eq charset 'utf-8)
- (condition-case nil
- (decode-coding-region (point) (point-max) charset)
- (coding-system-error nil)))
(let ((document
(or document
(list
'base (list (cons 'href url))
- (libxml-parse-html-region (point) (point-max)))))
- (source (buffer-substring (point) (point-max))))
+ (progn
+ (unless (eq charset 'utf-8)
+ (condition-case nil
+ (decode-coding-region (point) (point-max) charset)
+ (coding-system-error nil)))
+ (libxml-parse-html-region (point) (point-max))))))
+ (source (and (null document)
+ (buffer-substring (point) (point-max)))))
(eww-setup-buffer)
(setq eww-current-source source
eww-current-dom document)