aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/gnus/ChangeLog4
-rw-r--r--lisp/gnus/gnus-html.el76
2 files changed, 80 insertions, 0 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index d0ba8abf24a..e6e0ff07a11 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,7 @@
12010-08-29 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * gnus-html.el: Start a new super-simple HTML renderer based on w3m.
4
12010-08-28 Lars Magne Ingebrigtsen <larsi@gnus.org> 52010-08-28 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 6
3 * gnus.el (gnus-valid-select-methods): Remove reference to nngoogle, 7 * gnus.el (gnus-valid-select-methods): Remove reference to nngoogle,
diff --git a/lisp/gnus/gnus-html.el b/lisp/gnus/gnus-html.el
new file mode 100644
index 00000000000..65367758560
--- /dev/null
+++ b/lisp/gnus/gnus-html.el
@@ -0,0 +1,76 @@
1;;; gnus-html.el --- Quoted-Printable functions
2
3;; Copyright (C) 2010 Free Software Foundation, Inc.
4
5;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6;; Keywords: html, web
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software: you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22
23;;; Commentary:
24
25;; The idea is to provide a simple, fast and pretty minimal way to
26;; render HTML (including links and images) in a buffer, based on an
27;; external HTML renderer (i.e., w3m).
28
29;;; Code:
30
31;;;###autoload
32(defun gnus-article-html (handle)
33 (let ((article-buffer (current-buffer)))
34 (save-restriction
35 (narrow-to-region (point) (point))
36 (save-excursion
37 (set-buffer (car handle))
38 (call-process-region (point-min) (point-max)
39 "w3m"
40 nil article-buffer nil
41 "-halfdump"
42 "-T" "text/html"))
43 (gnus-html-wash-tags))))
44
45(defun gnus-html-wash-tags ()
46 (let (tag parameters string start end)
47 ;;(subst-char-in-region (point-min) (point-max) ?_ ? )
48 (goto-char (point-min))
49 (while (re-search-forward "<\\([^ ]+\\)\\([^>]*\\)>\\([^<]*\\)<[^>]*>" nil t)
50 (setq tag (match-string 1)
51 parameters (match-string 2)
52 string (match-string 3)
53 start (match-beginning 0)
54 end (+ start (length string)))
55 (replace-match string)
56 (cond
57 ;; Fetch and insert a picture.
58 ((equal tag "img_alt")
59 ;;
60 )
61 ;; Add a link.
62 ((equal tag "a")
63 (when (string-match "href=\"\\([^\"]+\\)" parameters)
64 (setq parameters (match-string 1 parameters))
65 (gnus-article-add-button start end
66 'browse-url parameters)
67 (let ((overlay (gnus-make-overlay start end)))
68 (gnus-overlay-put overlay 'evaporate t)
69 (gnus-overlay-put overlay 'gnus-button-url parameters)
70 (when gnus-article-mouse-face
71 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))))
72 ;; Whatever. Just ignore the tag.
73 (t
74 (replace-match string))))))
75
76;;; gnus-html.el ends here