diff options
| author | Lars Magne Ingebrigtsen | 2014-11-03 01:16:21 +0100 |
|---|---|---|
| committer | Lars Magne Ingebrigtsen | 2014-11-03 01:16:21 +0100 |
| commit | 54b3c985d6553e67de0b661aac3191bc87807c41 (patch) | |
| tree | 44c3abec4e02d380af4a44a2e0c43ee3a43f6007 | |
| parent | 2e8259b044fda2a6424b71eb8368cafa2fa6d86e (diff) | |
| download | emacs-54b3c985d6553e67de0b661aac3191bc87807c41.tar.gz emacs-54b3c985d6553e67de0b661aac3191bc87807c41.zip | |
Fix charset problems with the `R' command in eww
* net/eww.el (eww-display-html): The charset is called `utf-8',
not `utf8'.
(eww-readable): Decode the saved text correctly.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/net/eww.el | 18 |
2 files changed, 18 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b6e32f285ce..17d006604c8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-11-03 Lars Magne Ingebrigtsen <larsi@gnus.org> | ||
| 2 | |||
| 3 | * net/eww.el (eww-display-html): The charset is called `utf-8', | ||
| 4 | not `utf8'. | ||
| 5 | (eww-readable): Decode the saved text correctly. | ||
| 6 | |||
| 1 | 2014-11-02 Lars Magne Ingebrigtsen <larsi@gnus.org> | 7 | 2014-11-02 Lars Magne Ingebrigtsen <larsi@gnus.org> |
| 2 | 8 | ||
| 3 | * net/eww.el (eww-readable): New command and keystroke. | 9 | * net/eww.el (eww-readable): New command and keystroke. |
diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 579f0878bbd..0e74201173e 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el | |||
| @@ -256,7 +256,7 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 256 | (defun eww-display-html (charset url &optional document point) | 256 | (defun eww-display-html (charset url &optional document point) |
| 257 | (or (fboundp 'libxml-parse-html-region) | 257 | (or (fboundp 'libxml-parse-html-region) |
| 258 | (error "This function requires Emacs to be compiled with libxml2")) | 258 | (error "This function requires Emacs to be compiled with libxml2")) |
| 259 | (unless (eq charset 'utf8) | 259 | (unless (eq charset 'utf-8) |
| 260 | (condition-case nil | 260 | (condition-case nil |
| 261 | (decode-coding-region (point) (point-max) charset) | 261 | (decode-coding-region (point) (point-max) charset) |
| 262 | (coding-system-error nil))) | 262 | (coding-system-error nil))) |
| @@ -424,10 +424,14 @@ the like." | |||
| 424 | (dom (shr-transform-dom | 424 | (dom (shr-transform-dom |
| 425 | (with-temp-buffer | 425 | (with-temp-buffer |
| 426 | (insert source) | 426 | (insert source) |
| 427 | (condition-case nil | ||
| 428 | (decode-coding-region (point-min) (point-max) 'utf-8) | ||
| 429 | (coding-system-error nil)) | ||
| 427 | (libxml-parse-html-region (point-min) (point-max)))))) | 430 | (libxml-parse-html-region (point-min) (point-max)))))) |
| 428 | (eww-score-readability dom) | 431 | (eww-score-readability dom) |
| 429 | (eww-display-html 'utf-8 nil (shr-retransform-dom | 432 | (eww-display-html nil nil |
| 430 | (eww-highest-readability dom))) | 433 | (shr-retransform-dom |
| 434 | (eww-highest-readability dom))) | ||
| 431 | (setq eww-current-source source))) | 435 | (setq eww-current-source source))) |
| 432 | 436 | ||
| 433 | (defun eww-score-readability (node) | 437 | (defun eww-score-readability (node) |
| @@ -437,6 +441,8 @@ the like." | |||
| 437 | (setq score -2)) | 441 | (setq score -2)) |
| 438 | ((eq (car node) 'meta) | 442 | ((eq (car node) 'meta) |
| 439 | (setq score -1)) | 443 | (setq score -1)) |
| 444 | ((eq (car node) 'img) | ||
| 445 | (setq score 2)) | ||
| 440 | ((eq (car node) 'a) | 446 | ((eq (car node) 'a) |
| 441 | (setq score (- (length (split-string | 447 | (setq score (- (length (split-string |
| 442 | (or (cdr (assoc 'text (cdr node))) "")))))) | 448 | (or (cdr (assoc 'text (cdr node))) "")))))) |
| @@ -579,8 +585,8 @@ the like." | |||
| 579 | (let ((inhibit-read-only t)) | 585 | (let ((inhibit-read-only t)) |
| 580 | (erase-buffer) | 586 | (erase-buffer) |
| 581 | (insert (plist-get elem :text)) | 587 | (insert (plist-get elem :text)) |
| 582 | (setq eww-current-source (plist-get elem :source)) | 588 | (setq eww-current-source (plist-get elem :source) |
| 583 | (setq eww-current-dom (plist-get elem :dom)) | 589 | eww-current-dom (plist-get elem :dom)) |
| 584 | (goto-char (plist-get elem :point)) | 590 | (goto-char (plist-get elem :point)) |
| 585 | (setq eww-current-url (plist-get elem :url) | 591 | (setq eww-current-url (plist-get elem :url) |
| 586 | eww-current-title (plist-get elem :title)) | 592 | eww-current-title (plist-get elem :title)) |
| @@ -1105,7 +1111,7 @@ If EXTERNAL, browse the URL using `shr-external-browser'." | |||
| 1105 | ((and (url-target (url-generic-parse-url url)) | 1111 | ((and (url-target (url-generic-parse-url url)) |
| 1106 | (eww-same-page-p url eww-current-url)) | 1112 | (eww-same-page-p url eww-current-url)) |
| 1107 | (eww-save-history) | 1113 | (eww-save-history) |
| 1108 | (eww-display-html 'utf8 url eww-current-dom)) | 1114 | (eww-display-html 'utf-8 url eww-current-dom)) |
| 1109 | (t | 1115 | (t |
| 1110 | (eww-browse-url url))))) | 1116 | (eww-browse-url url))))) |
| 1111 | 1117 | ||