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

Re: [OT]: stripping html attachments



The following is a little bit better:

---<snip>---
##                                                                                                      
## HTML                                                                                                 
## strip all html off the email                                                                         
##                                                                                                      
:0 HB:                                                                                                  
* ^Content-Type: text/html                                                                              
{                                                                                                       
    :0 bfW:                                                                                             
    | /home/timo/bin/strip_html                                                                         
}           
---<snap>---

---<snip>---
#!/bin/sh                                                                                               
                                                                                                        
TMPFILE=$(mktemp /tmp/strip_html.XXXXXX)                                                                
                                                                                                        
echo "<PRE>" > $TMPFILE                                                                                 
                                                                                                        
cat /dev/stdin | \                                                                                      
        sed "s/Content-Type: text\/html/<\/PRE>Content-Type: text\/plain/;\                          
             s/<\/[Hh][Tt][Mm][Ll]>/<\/HTML><PRE>/;                       \                          
             s/<[Hh][Tt][Mm][Ll]>/<PRE>[HTML stripped]<\/PRE><HTML>/"     \                          
        >> $TMPFILE                                                                                     
                                                                                                        
echo "</PRE>" >> $TMPFILE                                                                               
                                                                                                        
w3m -dump -T text/html $TMPFILE                                                                         
                                                                                                        
rm $TMPFILE                                                                                             
---<snap>---                                                                                            

-timo

-- 
gpg key fingerprint = 6832 C8EC D823 4059 0CD1  6FBF 9383 7DBD 109E 98DC

Attachment: pgpREOjqD4wb3.pgp
Description: PGP signature


Reply to: