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

* Re: Using `links' to process HTML
  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-18  0:44 ` ShengHuo ZHU
  2 siblings, 0 replies; 16+ messages in thread
From: Nevin Kapur @ 2002-02-15 16:24 UTC (permalink / raw)
  Cc: ding

Hrvoje Niksic <hniksic@arsdigita.com> writes:

> [ 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.

I've been using this since you posted it yesterday.  Seems to work
really well, doing exactly what I want for HTML only mails.

Thanks!

-- 
Nevin



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

* Re: Using `links' to process HTML
  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-16 15:33   ` Nevin Kapur
  2002-02-18  0:44 ` ShengHuo ZHU
  2 siblings, 2 replies; 16+ messages in thread
From: Matthieu Moy @ 2002-02-16 14:09 UTC (permalink / raw)
  Cc: ding

Hrvoje Niksic <hniksic@arsdigita.com> writes:

> 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.

I have  something similar, which I  find much simpler  : The following
line in my .mailcap : 

text/html; lynx.sh %s; copiousoutput

Where lynx.sh is :

#!/bin/tcsh
set term=rxvt
lynx -dump -force_html "$1" -term=rxvt

What is the difference (except the use of lynx instead of links) ? 

-- 
Matthieu



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

* Re: Using `links' to process HTML
  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
  1 sibling, 1 reply; 16+ messages in thread
From: Hrvoje Niksic @ 2002-02-16 14:36 UTC (permalink / raw)
  Cc: ding

Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> I have  something similar, which I  find much simpler  : The following
> line in my .mailcap : 
>
> text/html; lynx.sh %s; copiousoutput
>
> Where lynx.sh is :
>
> #!/bin/tcsh
> set term=rxvt
> lynx -dump -force_html "$1" -term=rxvt
>
> What is the difference (except the use of lynx instead of links) ?

Two differences:

* I never bothered to read up on what you can do with `.mailcap'.  I
  preferred hacking Lisp.  :-)

* Links is so much cooler than lynx.  For one, it handles HTML tables
  correctly.



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

* Re: Using `links' to process HTML
  2002-02-16 14:09 ` Matthieu Moy
  2002-02-16 14:36   ` Hrvoje Niksic
@ 2002-02-16 15:33   ` Nevin Kapur
  2002-02-16 16:16     ` Kai Großjohann
  1 sibling, 1 reply; 16+ messages in thread
From: Nevin Kapur @ 2002-02-16 15:33 UTC (permalink / raw)
  Cc: Hrvoje Niksic, ding

Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> I have  something similar, which I  find much simpler  : The following
> line in my .mailcap : 
>
> text/html; lynx.sh %s; copiousoutput

Doesn't that make it a global setting?  I, for one, am only interested
in l[iy]nks handle text/html when I'm reading mail from within Gnus.

-- 
Nevin



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

* Re: Using `links' to process HTML
  2002-02-16 15:33   ` Nevin Kapur
@ 2002-02-16 16:16     ` Kai Großjohann
  2002-02-16 18:02       ` Nuutti Kotivuori
                         ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Kai Großjohann @ 2002-02-16 16:16 UTC (permalink / raw)
  Cc: Hrvoje Niksic, ding

Nevin Kapur <nevin@jhu.edu> writes:

> Doesn't that make it a global setting?  I, for one, am only interested
> in l[iy]nks handle text/html when I'm reading mail from within Gnus.

I think that .mailcap supports tests.  But I'm not sure if there is a
test which evals to true for Gnus and false otherwise.

To be sure, you can add the entry in mailcap-mime-data directly.

IIRC, there is something similar for w3m but with that solution it is
even possible to follow links!

kai
-- 
~/.signature is: umop 3p!sdn    (Frank Nobis)



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

* Re: Using `links' to process HTML
  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
  2 siblings, 0 replies; 16+ messages in thread
From: Nuutti Kotivuori @ 2002-02-16 18:02 UTC (permalink / raw)


Kai Großjohann wrote:
> Nevin Kapur <nevin@jhu.edu> writes:
> 
>> Doesn't that make it a global setting?  I, for one, am only
>> interested in l[iy]nks handle text/html when I'm reading mail from
>> within Gnus.
> 
> I think that .mailcap supports tests.  But I'm not sure if there is
> a test which evals to true for Gnus and false otherwise.
> 
> To be sure, you can add the entry in mailcap-mime-data directly.
> 
> IIRC, there is something similar for w3m but with that solution it
> is even possible to follow links!

I'm using w3m-el with some hacks copied somewhere to integrate it with
gnus. All HTML mails are rendered inline, with links and tables and
the ability to browse them. Renders pictures inline as well, if I ask
it to (I don't, usually).

-- Naked




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

* Re: Using `links' to process HTML
  2002-02-16 14:36   ` Hrvoje Niksic
@ 2002-02-17 17:36     ` Steinar Bang
  0 siblings, 0 replies; 16+ messages in thread
From: Steinar Bang @ 2002-02-17 17:36 UTC (permalink / raw)
  Cc: Hrvoje Niksic

>>>>> Hrvoje Niksic <hniksic@arsdigita.com>:

> Matthieu Moy <Matthieu.Moy@imag.fr> writes:

>> What is the difference (except the use of lynx instead of links) ?

> * Links is so much cooler than lynx.  For one, it handles HTML
> tables correctly.

Links (0.96.20011222 on debian testing) doesn't seem to do HTTP Basic
auth, though.



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

* Re: Using `links' to process HTML
  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-18  0:44 ` ShengHuo ZHU
  2002-02-18  8:55   ` Matthieu Moy
  2002-02-18 15:37   ` Steve Youngs
  2 siblings, 2 replies; 16+ messages in thread
From: ShengHuo ZHU @ 2002-02-18  0:44 UTC (permalink / raw)
  Cc: Hrvoje Niksic

Hrvoje Niksic <hniksic@arsdigita.com> writes:

> [ 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.

Inspired by the code, I added a new feature which enables users to
choose w3, w3m, links or lynx to render HTML parts. For example,

     (setq mm-text-html-renderer 'links)

(I don't have links installed. Please test.)

This variable can be overridden if mm-inline-text-html-renderer is
set. Also, gnus-article-wash-html uses this variable too.

If anyone knows some external commands to render html or other MIME
type, please post the solutions. Something like html2txt or word2txt.

ShengHuo



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

* Re: Using `links' to process HTML
  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
  1 sibling, 1 reply; 16+ messages in thread
From: Matthieu Moy @ 2002-02-18  8:55 UTC (permalink / raw)


ShengHuo ZHU <zsh@cs.rochester.edu> writes:

> If anyone knows some external commands to render html or other MIME
> type, please post the solutions. Something like html2txt or word2txt.

There is antiword or catdoc for  M$ word .doc files. Very usefull when
people  use word  for typing  plain  text, and  then send  it by  mail
(Aarrgh !).  Its  behaviour is similar to lynx -dump.  See if you want
to add something  about this. But I think  .mailcap and its equivalent
in  elisp  are sufficient.  Maybe  add some  tips  about  this in  the
documentation.

,----[ ~/.mailcap ]
| application/msword; catdoc %s ; copiousoutput ; nametemplate=%s.doc
`----

-- 
Matthieu



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

* Re: Using `links' to process HTML
  2002-02-18  8:55   ` Matthieu Moy
@ 2002-02-18 15:34     ` ShengHuo ZHU
  0 siblings, 0 replies; 16+ messages in thread
From: ShengHuo ZHU @ 2002-02-18 15:34 UTC (permalink / raw)


Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> ShengHuo ZHU <zsh@cs.rochester.edu> writes:
>
>> If anyone knows some external commands to render html or other MIME
>> type, please post the solutions. Something like html2txt or word2txt.
>
> There is antiword or catdoc for  M$ word .doc files. Very usefull when
> people  use word  for typing  plain  text, and  then send  it by  mail
> (Aarrgh !).  Its  behaviour is similar to lynx -dump.  See if you want
> to add something  about this. But I think  .mailcap and its equivalent
> in  elisp  are sufficient.  Maybe  add some  tips  about  this in  the
> documentation.
>
> ,----[ ~/.mailcap ]
> | application/msword; catdoc %s ; copiousoutput ; nametemplate=%s.doc
> `----

You are right. I've added copiousoutput in the documentation.

ShengHuo



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

* Re: Using `links' to process HTML
  2002-02-18  0:44 ` ShengHuo ZHU
  2002-02-18  8:55   ` Matthieu Moy
@ 2002-02-18 15:37   ` Steve Youngs
  2002-02-18 18:48     ` ShengHuo ZHU
  1 sibling, 1 reply; 16+ messages in thread
From: Steve Youngs @ 2002-02-18 15:37 UTC (permalink / raw)


|--==> "ZSH" == ShengHuo ZHU <zsh@cs.rochester.edu> writes:

  ZSH>      (setq mm-text-html-renderer 'links)

With (setq mm-text-html-renderer 'lynx) I'm getting an error back from
lynx:  "Unknown option '-stdin'".



-- 
|---<Steve Youngs>---------------<GnuPG KeyID: 10D5C9C5>---|
|            XEmacs - It's not just an editor.             |
|                    It's a way of life.                   |
|------------------------------------<youngs@xemacs.org>---|



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

* Re: Using `links' to process HTML
  2002-02-18 15:37   ` Steve Youngs
@ 2002-02-18 18:48     ` ShengHuo ZHU
  2002-02-18 23:14       ` Steve Youngs
  0 siblings, 1 reply; 16+ messages in thread
From: ShengHuo ZHU @ 2002-02-18 18:48 UTC (permalink / raw)


Steve Youngs <youngs@xemacs.org> writes:

> |--==> "ZSH" == ShengHuo ZHU <zsh@cs.rochester.edu> writes:
>
>   ZSH>      (setq mm-text-html-renderer 'links)
>
> With (setq mm-text-html-renderer 'lynx) I'm getting an error back from
> lynx:  "Unknown option '-stdin'".

I got the option. Maybe it is because of the different versions of
lynx.

$ lynx -version
Lynx Version 2.8.4rel.1 (17 Jul 2001)
libwww-FM 2.14, SSL-MM 1.4.1, OpenSSL 0.9.6b
Built on linux-gnu Jul 31 2001 09:03:10


ShengHuo



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

* Re: Using `links' to process HTML
  2002-02-18 18:48     ` ShengHuo ZHU
@ 2002-02-18 23:14       ` Steve Youngs
  0 siblings, 0 replies; 16+ messages in thread
From: Steve Youngs @ 2002-02-18 23:14 UTC (permalink / raw)


|--==> "ZSH" == ShengHuo ZHU <zsh@cs.rochester.edu> writes:

  ZSH> Steve Youngs <youngs@xemacs.org> writes:
  >>|--==> "ZSH" == ShengHuo ZHU <zsh@cs.rochester.edu> writes:
  >>
  ZSH> (setq mm-text-html-renderer 'links)
  >>
  >>With (setq mm-text-html-renderer 'lynx) I'm getting an error back from
  >>lynx:  "Unknown option '-stdin'".

  ZSH> I got the option. Maybe it is because of the different versions of
  ZSH> lynx.

That was it.  Updating lynx fixed it.

-- 
|---<Steve Youngs>---------------<GnuPG KeyID: 10D5C9C5>---|
|            XEmacs - It's not just an editor.             |
|                    It's a way of life.                   |
|------------------------------------<youngs@xemacs.org>---|



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

* Re: Using `links' to process HTML
  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
  2 siblings, 0 replies; 16+ messages in thread
From: Paul Jarc @ 2002-02-21 19:37 UTC (permalink / raw)


Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) wrote:
> I think that .mailcap supports tests.  But I'm not sure if there is a
> test which evals to true for Gnus and false otherwise.

You could add (setenv "CALLER" "Gnus") in .gnus, and the shell command
in .mailcap could do different things for different $CALLERs.


paul



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

* Re: Using `links' to process HTML
  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
  2 siblings, 0 replies; 16+ messages in thread
From: Paul Jarc @ 2002-02-21 19:37 UTC (permalink / raw)


Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) wrote:
> I think that .mailcap supports tests.  But I'm not sure if there is a
> test which evals to true for Gnus and false otherwise.

You could add (setenv "CALLER" "Gnus") in .gnus, and the shell command
in .mailcap could do different things for different $CALLERs.


paul



^ 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).