Gnus development mailing list
 help / color / mirror / Atom feed
* Using `links' to process HTML
@ 2002-02-14  7:08 Hrvoje Niksic
  2002-02-15 16:24 ` Nevin Kapur
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Hrvoje Niksic @ 2002-02-14  7:08 UTC (permalink / raw)


[ Note: I'm not on the list.  If you want me to see your replies, add Cc. ]

I've been using this for some time now and want to share it with
others.  It hooks into the processing of "text/html" and renders it by
noninteractively calling the textual browser `links'.  Although this
doesn't support images, colors, forms and whatnot, those are the
things I turn off anyway.  It does support tables, however.

Overall it does a much better job of rendering HTML than w3 does.  My
spams finally come out right before I ignore them.

Here is what I put in `.gnus'.  It relies on the program `links' being
somewhere on the PATH.  If you try it, please let me know if it works
for you.

(eval-after-load "mm-decode"
  '(push '("text/html"
	   my-html-handler
	   (lambda (handle) t))
	 mm-inline-media-tests))

;; If you're not running under XEmacs...
(unless (fboundp 'temp-directory)
  (defun temp-directory ()
    (or (getenv "TMPDIR") "/tmp")))

(defun my-html-handler (handle)
  (let ((source (mm-get-part handle))
	(tmpfile (make-temp-name (expand-file-name
				  "www" (temp-directory))))
	text)
    (with-temp-buffer
      (insert source)
      (write-region (point-min) (point-max) tmpfile nil 'silent)
      (delete-region (point-min) (point-max))
      (unwind-protect
	  ;; It would be nice if we could use `call-process-region' to
	  ;; feed the HTML to links's stdin thus avoiding the tmpfile.
	  ;; But `links -dump /dev/stdin' doesn't work when stdin is a
	  ;; pipe.
	  (call-process "links" nil t nil "-dump" tmpfile)
	(delete-file tmpfile))

      ;; Delete the annoying three spaces preceding each line of links
      ;; output.
      (goto-char (point-min))
      (while (re-search-forward "^   " nil t)
	(delete-region (match-beginning 0) (match-end 0)))

      (setq text (buffer-string)))

    (mm-insert-inline handle text)))



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2002-02-21 19:37 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-14  7:08 Using `links' to process HTML Hrvoje Niksic
2002-02-15 16:24 ` Nevin Kapur
2002-02-16 14:09 ` Matthieu Moy
2002-02-16 14:36   ` Hrvoje Niksic
2002-02-17 17:36     ` Steinar Bang
2002-02-16 15:33   ` Nevin Kapur
2002-02-16 16:16     ` Kai Großjohann
2002-02-16 18:02       ` Nuutti Kotivuori
2002-02-21 19:37       ` Paul Jarc
2002-02-21 19:37       ` Paul Jarc
2002-02-18  0:44 ` ShengHuo ZHU
2002-02-18  8:55   ` Matthieu Moy
2002-02-18 15:34     ` ShengHuo ZHU
2002-02-18 15:37   ` Steve Youngs
2002-02-18 18:48     ` ShengHuo ZHU
2002-02-18 23:14       ` Steve Youngs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).