Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Re: html mail filter in gnus
       [not found] <7ifzw8tp5z.fsf@neoscale.com>
  2002-09-17 22:16 ` html mail filter in gnus James Cozine
@ 2002-09-18  8:57 ` Jonas Steverud
       [not found] ` <87hegnjc3f.fsf@computer.localdomain>
  2 siblings, 0 replies; 5+ messages in thread
From: Jonas Steverud @ 2002-09-18  8:57 UTC (permalink / raw)


Kin Cho <kin@neoscale.com> writes:

> Hi,
>
> I'm getting html mail quite often now and it's getting annoying.
> Does anyone has a gnus filter to filter out the html tags and
> leave the plain text behind?

I've added the following during the pGnus days:

(add-to-list 'mm-inline-media-tests '("text/html" nil (lambda (h) nil)))
(add-to-list 'mm-discouraged-alternatives "text/html")
(add-to-list 'mm-discouraged-alternatives "text/richtext")
(add-to-list 'mm-discouraged-alternatives "text/enriched")
(setq mm-automatic-display (remove "text/html" mm-automatic-display))
(setq mm-automatic-display (remove "text/richtext" mm-automatic-display))
(setq mm-automatic-display (remove "text/enriched" mm-automatic-display))

It doesn't handle all possible, broken ways HTML can get to you but it
helps a bit.

(Improvements that doesn't involve W3 or similar are welcome.)

-- 
(          www.dtek.chalmers.se/~d4jonas/         !     Wei Wu Wei     )
(        Meaning of U2 Lyrics, Roleplaying        !  To Do Without Do  )


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

* Re: html mail filter in gnus
       [not found] ` <87hegnjc3f.fsf@computer.localdomain>
@ 2002-09-19 20:28   ` Kin Cho
       [not found]   ` <7i8z1xzpuc.fsf@neoscale.com>
  1 sibling, 0 replies; 5+ messages in thread
From: Kin Cho @ 2002-09-19 20:28 UTC (permalink / raw)


D. Goel <deego@glue.umd.edu> writes:

> > Hi,
> > 
> > I'm getting html mail quite often now and it's getting annoying.
> > Does anyone has a gnus filter to filter out the html tags and
> > leave the plain text behind?
> 
> 
> this shows you the lynxed mail.. this got into my .gnus from an
> earlier post in g.e.gnus --->
> 
> 
> ;; function to call to handle text/html attachments
> (defun my:gnus-html2text (handle)
>   (let (text)
>     (with-temp-buffer
>       (mm-insert-part handle)
>       (save-window-excursion
>   	(my:html2text-region (point-min) (point-max))
>   	(setq text (buffer-string))))
>     (mm-insert-inline handle text)))
> 
> (defun my:html2text-region (min max)
>   "Replace the HTML region from MIN to MAX with lynx --dump."
>   (interactive "r")
>   (let ((file "~/tmp/email.html"))
>     (unwind-protect
>         (progn
>           (write-region min max file)
>           (delete-region min max)
>           (insert (shell-command-to-string
>                    (concat "lynx "
>                            "lynx -dump "
>                            (shell-quote-argument
>                             (expand-file-name file))))))
>       ;;(delete-file file)
>       )))

Hi,

This approach seems to best fit my need.  How do you hook
my:gnus-html2text into gnus so that it is run automatically on
html mail?

Thanks.

-kin


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

* Re: html mail filter in gnus
       [not found]       ` <87n0qd1ypw.fsf@computer.localdomain>
@ 2002-09-20 15:17         ` Nils Goesche
       [not found]         ` <lky99wlmg2.fsf@pc022.bln.elmeg.de>
  1 sibling, 0 replies; 5+ messages in thread
From: Nils Goesche @ 2002-09-20 15:17 UTC (permalink / raw)


D. Goel <deego@glue.umd.edu> writes:

[howto use lynx for HTML MIME parts]

And after a few changes, it works fine for me, too.  Thanks!

Here everything together:


(defun my:gnus-html2text (handle)
  (let (text)
    (with-temp-buffer
      (mm-with-unibyte-buffer
	(mm-insert-part handle)
	(save-window-excursion
	  (my:html2text-region (point-min) (point-max))
	  (setq text (buffer-string)))))
    (mm-insert-inline handle text)))

(defun my:html2text-region (min max)
  "Replace the HTML region from MIN to MAX with lynx --dump."
  (interactive "r")
  (let ((file "/tmp/email.html"))
    (unwind-protect
	 (progn
	   (write-region min max file)
	   (delete-region min max)
	   (insert (shell-command-to-string
		    (concat "lynx "
			    "lynx -dump "
			    (shell-quote-argument
			     (expand-file-name file))))))
      (delete-file file))))

(setq mm-inline-media-tests
      (cons '("text/html" my:gnus-html2text
	      (lambda (handle)
		(fboundp 'my:gnus-html2text)))
	    (let ((old (assoc "text/html" mm-inline-media-tests)))
	      (if old
		  (delete old mm-inline-media-tests)
		  mm-inline-media-tests))))

Regards,
-- 
Nils Goesche
"Don't ask for whom the <CTRL-G> tolls."

PGP key ID 0x0655CFA0


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

* Re: html mail filter in gnus
       [not found]             ` <lklm5wleze.fsf@pc022.bln.elmeg.de>
@ 2002-09-24 22:06               ` D. Goel
  0 siblings, 0 replies; 5+ messages in thread
From: D. Goel @ 2002-09-24 22:06 UTC (permalink / raw)



(See Robin Socha's mail in a similar thread pointing to the page: 
http://my.gnus.org/Lisp/1012919677 )

[1] I was missing the 'credits' line in my .gnus---apologies for that.
i now see that that code was written by Mark Thomas.

[2] The code is perhaps now improved further on that page. 

[3] in any case, The code may have now been rendered obsolete (?) ---
the page says so.. (by gnus-art.el?)

DG                                 http://24.197.159.102/~deego/
--


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

* Re: html mail filter in gnus
       [not found] <7ifzw8tp5z.fsf@neoscale.com>
@ 2002-09-17 22:16 ` James Cozine
  2002-09-18  8:57 ` Jonas Steverud
       [not found] ` <87hegnjc3f.fsf@computer.localdomain>
  2 siblings, 0 replies; 5+ messages in thread
From: James Cozine @ 2002-09-17 22:16 UTC (permalink / raw)


Kin Cho <kin@neoscale.com> writes:

> Hi,
> 
> I'm getting html mail quite often now and it's getting annoying.
> Does anyone has a gnus filter to filter out the html tags and
> leave the plain text behind?
> 
> -kin

,----[ C-h v mm-discouraged-alternatives RET ]
| mm-discouraged-alternatives's value is 
| ("text/html" "text/richtext")
| 
| 
| Documentation:
| List of MIME types that are discouraged when viewing multipart/alternative.
| Viewing agents are supposed to view the last possible part of a message,
| as that is supposed to be the richest.  However, users may prefer other
| types instead, and this list says what types are most unwanted.  If,
| for instance, text/html parts are very unwanted, and text/richtext are
| somewhat unwanted, then the value of this variable should be set
| to:
| 
|  ("text/html" "text/richtext")
| 
| You can customize this variable.
| 
| Defined in `mm-decode'.
`----

-jc
-- 
Debug is human, de-fix divine.


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

end of thread, other threads:[~2002-09-24 22:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <7ifzw8tp5z.fsf@neoscale.com>
2002-09-17 22:16 ` html mail filter in gnus James Cozine
2002-09-18  8:57 ` Jonas Steverud
     [not found] ` <87hegnjc3f.fsf@computer.localdomain>
2002-09-19 20:28   ` Kin Cho
     [not found]   ` <7i8z1xzpuc.fsf@neoscale.com>
     [not found]     ` <87r8fp1yue.fsf@computer.localdomain>
     [not found]       ` <87n0qd1ypw.fsf@computer.localdomain>
2002-09-20 15:17         ` Nils Goesche
     [not found]         ` <lky99wlmg2.fsf@pc022.bln.elmeg.de>
     [not found]           ` <87it10vccm.fsf@computer.localdomain>
     [not found]             ` <lklm5wleze.fsf@pc022.bln.elmeg.de>
2002-09-24 22:06               ` D. Goel

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