From: Hrvoje Niksic <hniksic@arsdigita.com>
Subject: Using `links' to process HTML
Date: Thu, 14 Feb 2002 08:08:53 +0100 [thread overview]
Message-ID: <sxsu1skr14q.fsf@florida.arsdigita.de> (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)))
next reply other threads:[~2002-02-14 7:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-14 7:08 Hrvoje Niksic [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sxsu1skr14q.fsf@florida.arsdigita.de \
--to=hniksic@arsdigita.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).