10 November 2004 1 comment Python
If you missed the entry about Add links to text with URLs I suggest you read that first. This script has now been improved with bug fixes thanks to David Otton and Flump Cakes.
It does not come with a nice installer because I don't think it belongs to the generic Python library anyway. If you want to use it, copy the file
addhrefs.py to somewhere useful.
This is how it works:
>>> from addhrefs import addhrefs >>> t='''Hello www.peterbe.com and peterbe.com go to http://user:email@example.com send to firstname.lastname@example.org or <email@example.com>''' >>> print addhrefs(t) Hello <a href="http://www.peterbe.com">www.peterbe.com</a> and peterbe.com go to <a href="http://user:firstname.lastname@example.org">http://user:email@example.com</a> send to <a href="mailto:firstname.lastname@example.org">email@example.com</a> or <<a href="mailto:firstname.lastname@example.org">email@example.com</a>>
The example might be confusing since the Python code highlighter tries to do what
UPDATE: Link to
addhrefs-0.4.tgz didn't work before. Now it does.