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

Re: UrlView strangeness



> I use mutt which uses urlview to present a list of url's in a message.
> Lately, sometimes some of the lines in that list are blank (sometimes
> they're *all* blank). If I count the url's in the message and arrow down
> to the appropriate blank line it fires up lynx and takes me where I want
> to go.
> 
> Has anyone else experienced this?

I can't solve your specific problem, but you might be interested in what
I did. Feel free to ask, if something isn't clear.

Since I was not satisfied with urlview (just URLs, no context), I
defined 2 keybindings in .muttrc

    macro index \cb "|formail -I \"\" | txt2html.py > $HOME/tmp/tmp.html\n!links $HOME/tmp/tmp.html\n"
    macro pager \cb ...[the rest is the same]...

The script txt2html.py:

    #! /usr/bin/env python

    """txt2html - Convert plain text to html with urls as links.

    Usage: txt2html < in.txt > out.html
    """

    import sys, re

    url_rexp = re.compile(r"(http|https|ftp)://[-a-zA-Z:0-9./#%+~_?=&()@]+")

    def replace(match_object):
	url = match_object.group(0)
	return """<a href="%(url)s">%(url)s</a>""" % vars()

    txt = sys.stdin.read()
    html = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8559-1">
    <title>Converted by txt2html</title>
    </head>
    <body>
    <pre>
    %s
    </pre>
    </body>
    </html>
    """ % url_rexp.sub(replace, txt)
    sys.stdout.write(html)

Stony



Reply to: