emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r101211: Add a new super-simple HTML


From: Katsumi Yamaoka
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101211: Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <address@hidden>.
Date: Mon, 30 Aug 2010 06:13:50 +0000
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101211
committer: Katsumi Yamaoka <address@hidden>
branch nick: trunk
timestamp: Mon 2010-08-30 06:13:50 +0000
message:
  Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne 
Ingebrigtsen <address@hidden>.
  
   * gnus-html.el: Start a new super-simple HTML renderer based on w3m.
added:
  lisp/gnus/gnus-html.el
modified:
  lisp/gnus/ChangeLog
=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog       2010-08-30 06:10:18 +0000
+++ b/lisp/gnus/ChangeLog       2010-08-30 06:13:50 +0000
@@ -1,3 +1,7 @@
+2010-08-29  Lars Magne Ingebrigtsen  <address@hidden>
+
+       * gnus-html.el: Start a new super-simple HTML renderer based on w3m.
+
 2010-08-28  Lars Magne Ingebrigtsen  <address@hidden>
 
        * gnus.el (gnus-valid-select-methods): Remove reference to nngoogle,

=== added file 'lisp/gnus/gnus-html.el'
--- a/lisp/gnus/gnus-html.el    1970-01-01 00:00:00 +0000
+++ b/lisp/gnus/gnus-html.el    2010-08-30 06:13:50 +0000
@@ -0,0 +1,76 @@
+;;; gnus-html.el --- Quoted-Printable functions
+
+;; Copyright (C) 2010  Free Software Foundation, Inc.
+
+;; Author: Lars Magne Ingebrigtsen <address@hidden>
+;; Keywords: html, web
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; The idea is to provide a simple, fast and pretty minimal way to
+;; render HTML (including links and images) in a buffer, based on an
+;; external HTML renderer (i.e., w3m).
+
+;;; Code:
+
+;;;###autoload
+(defun gnus-article-html (handle)
+  (let ((article-buffer (current-buffer)))
+    (save-restriction
+      (narrow-to-region (point) (point))
+      (save-excursion
+       (set-buffer (car handle))
+       (call-process-region (point-min) (point-max)
+                            "w3m" 
+                            nil article-buffer nil
+                            "-halfdump"
+                            "-T" "text/html"))
+      (gnus-html-wash-tags))))
+
+(defun gnus-html-wash-tags ()
+  (let (tag parameters string start end)
+    ;;(subst-char-in-region (point-min) (point-max) ?_ ? )
+    (goto-char (point-min))
+    (while (re-search-forward "<\\([^ ]+\\)\\([^>]*\\)>\\([^<]*\\)<[^>]*>" nil 
t)
+      (setq tag (match-string 1)
+           parameters (match-string 2)
+           string (match-string 3)
+           start (match-beginning 0)
+           end (+ start (length string)))
+      (replace-match string)
+      (cond
+       ;; Fetch and insert a picture.
+       ((equal tag "img_alt")
+       ;;
+       )
+       ;; Add a link.
+       ((equal tag "a")
+       (when (string-match "href=\"\\([^\"]+\\)" parameters)
+         (setq parameters (match-string 1 parameters))
+         (gnus-article-add-button start end
+                                  'browse-url parameters)
+         (let ((overlay (gnus-make-overlay start end)))
+           (gnus-overlay-put overlay 'evaporate t)
+           (gnus-overlay-put overlay 'gnus-button-url parameters)
+           (when gnus-article-mouse-face
+             (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))))
+       ;; Whatever.  Just ignore the tag.
+       (t
+       (replace-match string))))))
+
+;;; gnus-html.el ends here


reply via email to

[Prev in Thread] Current Thread [Next in Thread]