]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix charset problems with the `R' command in eww
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Mon, 3 Nov 2014 00:16:21 +0000 (01:16 +0100)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Mon, 3 Nov 2014 00:16:21 +0000 (01:16 +0100)
* net/eww.el (eww-display-html): The charset is called `utf-8',
not `utf8'.
(eww-readable): Decode the saved text correctly.

lisp/ChangeLog
lisp/net/eww.el

index b6e32f285ce8a4a22e3e8ed5f05af67f330c74fe..17d006604c8119b8800cf97867370316916f3064 100644 (file)
@@ -1,3 +1,9 @@
+2014-11-03  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * net/eww.el (eww-display-html): The charset is called `utf-8',
+       not `utf8'.
+       (eww-readable): Decode the saved text correctly.
+
 2014-11-02  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * net/eww.el (eww-readable): New command and keystroke.
index 579f0878bbd5c5f8815c921865dad35fe13ac0dd..0e74201173e8ad83b301d7ce43cf2dee5834f421 100644 (file)
@@ -256,7 +256,7 @@ word(s) will be searched for via `eww-search-prefix'."
 (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 'utf8)
+  (unless (eq charset 'utf-8)
     (condition-case nil
        (decode-coding-region (point) (point-max) charset)
       (coding-system-error nil)))
@@ -424,10 +424,14 @@ the like."
         (dom (shr-transform-dom
               (with-temp-buffer
                 (insert source)
+                (condition-case nil
+                    (decode-coding-region (point-min) (point-max) 'utf-8)
+                  (coding-system-error nil))
                 (libxml-parse-html-region (point-min) (point-max))))))
     (eww-score-readability dom)
-    (eww-display-html 'utf-8 nil (shr-retransform-dom
-                                 (eww-highest-readability dom)))
+    (eww-display-html nil nil
+                     (shr-retransform-dom
+                      (eww-highest-readability dom)))
     (setq eww-current-source source)))
 
 (defun eww-score-readability (node)
@@ -437,6 +441,8 @@ the like."
       (setq score -2))
      ((eq (car node) 'meta)
       (setq score -1))
+     ((eq (car node) 'img)
+      (setq score 2))
      ((eq (car node) 'a)
       (setq score (- (length (split-string
                              (or (cdr (assoc 'text (cdr node))) ""))))))
@@ -579,8 +585,8 @@ the like."
   (let ((inhibit-read-only t))
     (erase-buffer)
     (insert (plist-get elem :text))
-    (setq eww-current-source (plist-get elem :source))
-    (setq eww-current-dom (plist-get elem :dom))
+    (setq eww-current-source (plist-get elem :source)
+         eww-current-dom (plist-get elem :dom))
     (goto-char (plist-get elem :point))
     (setq eww-current-url (plist-get elem :url)
          eww-current-title (plist-get elem :title))
@@ -1105,7 +1111,7 @@ If EXTERNAL, browse the URL using `shr-external-browser'."
      ((and (url-target (url-generic-parse-url url))
           (eww-same-page-p url eww-current-url))
       (eww-save-history)
-      (eww-display-html 'utf8 url eww-current-dom))
+      (eww-display-html 'utf-8 url eww-current-dom))
      (t
       (eww-browse-url url)))))