Add links to a text (take II)

10 November 2004   2 comments   Python

Mind That Age!

This blog post is 14 years old! Most likely, its content is outdated. Especially if it's technical.

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.

Download: addhrefs-0.4.tgz
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:pass@google.ca
send to mail@email.com 
or <here@there.com>'''
>>> print addhrefs(t)
Hello <a href="https://www.peterbe.com">www.peterbe.com</a>
and peterbe.com go to <a  href="http://user:pass@google.ca">http://user:pass@google.ca</a>
send to <a href="mailto:mail@email.com">mail@email.com</a> 
or <<a  href="mailto:here@there.com">here@there.com</a>>

The example might be confusing since the Python code highlighter tries to do what addhrefs does.

UPDATE: Link to addhrefs-0.4.tgz didn't work before. Now it does.

Comments

Bob Marley
Hello? people! visit to my site!
Justin
I don't know how I found this, but it's strange. Thanks

Your email will never ever be published


Related posts

Previous:
XHTML Transitional versus Strict 05 November 2004
Next:
Indent text like email clients do 11 November 2004
Related by Keyword:
Control comment spam 05 April 2005
Add links to a text (take III) 22 March 2005
Google is blind 24 January 2005
Add links to a text with URLs 03 November 2004
Accessible Pop-Up script 08 June 2004
Related by Text:
Be very careful with your add_header in Nginx! You might make your site insecure 11 February 2018
jQuery and Highslide JS 08 January 2008
I'm back! Peterbe.com has been renewed 05 June 2005
Anti-McCain propaganda videos 12 August 2008
I'm Prolog 01 May 2007