On Mon, Jul 02, 2001 at 03:09:09PM -0700, Tim Condit wrote: > Someone was asking about this a few days ago.. I deleted the email, but > went to the list archives and found it. > > > However, it could also be useful to select an URL in the message > > body and just bookmark it for later viewing, or print it using the > > printing capabilities of the browser. I am thinking to some > > macros that would use the "netscape remote control capabilities" > > explained in: FWIW - I'll repost a script I've found handy to bring up the entire email in a browser with URLs converted to true hyperlinks. This allows you to use the built-in browser facilities to manage bookmarks, history, etc. To use it you need something like this to make a Ctrl-B macro in .muttrc. macro index \Cb "| python email2html.py > /tmp/urlview.htm; netscape /tmp/urlview.htm" HTH - Regards, Steve -- \_O< \_O< \_O< ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steve Cooper Redmond, WA
#!/usr/bin/env python2 ############################################################### # Pipe filter to convert email to html # # STDIN=text email # STDOUT=html-ized email # # Add something like the following to your .muttrc # macro pager \Cb "| python email2html.py > /tmp/urlview.htm; netscape /tmp/urlview.htm" # # **USE AT YOUR OWN RISK** # # Enjoy! # Steve Cooper ############################################################### import sys import re #=== Globals # Regular expression for isolating URLs reURL = re.compile('(((http|https|ftp|gopher)|mailto)[.:][^ >"\t]*|www\.[-a-z0-9.]+)') # Colors bgColor = "#ffffff" labelColor = "#5050e0" textColor = "#000000" #=== Fix line function def FixLine(line): line = line.strip() line = line.replace('<','<') line = line.replace('>','>') return line #=== Header list class class HeaderList: def __init__(self): self.headers = {} # Specification for desired visible headers # TODO: Un-hardcode this! self.reHeaders = re.compile('^[ \t]*(From|To|Date|Subject):[ \t]*(.*)$', re.IGNORECASE) def ScanLine(self, line): matchHeader = self.reHeaders.search(line) if matchHeader is not None: self.headers[matchHeader.group(1).lower()] = matchHeader.group(2) def OutputLine(self, name, label, size = "+0"): if self.headers.has_key(name): print '<b><font color="%s" size="%s">%s: </font></b>' % (labelColor, size, label) print '<font color="%s" size="%s">%s</font><br>' % (textColor, size, self.headers[name]) def Output(self): # TODO: Un-hardcode this! self.OutputLine('from', 'From') self.OutputLine('to', 'To', '-1') self.OutputLine('date', 'Date', '-1') self.OutputLine('subject', 'Subject', '+1') print '<hr><br>' print '<html>' print '<head>' print '<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">' print '<title>Mutt Email</title>' print '</head>' print '<body bgcolor="%s">' % bgColor #=== Scan headers headers = HeaderList() line = sys.stdin.readline() while line: line = FixLine(line) # Assume first empty line is the end of the headers if not line: break headers.ScanLine(line) line = sys.stdin.readline() #=== Format header lines headers.Output() #=== Scan and display body print '<PRE>' nLine = 0 line = sys.stdin.readline() while line: line = FixLine(line) nLine = nLine + 1 match = reURL.search(line) while match is not None: sub = '<a href="%s">%s</a>' % (match.group(1), match.group(1)) line = line[:match.start(1)] + sub + line[match.end():] skip = match.start() + len(sub) match = reURL.search(line, skip) print '%s' % line line = sys.stdin.readline() print '</PRE>' print '</body>' print '</html>'