Crosstips.org

My fun Crossword solver project. Crosstips.org & Krysstips.se

Kung Fu

Fujian White Crane Kung Fu

Fry-IT

Fry-IT is the company I work for

Photos

Photoalbum, both old and new.

Zope

What I have and am doing with Zope

Receptsamlingen

In Swedish only. About my "Collection of Recipes" website.

Contact me

My contact details and how to contact me.

 

KungFuPeople.com
Do you train Kung Fu?
Or know someone who does?
Then check out KungFuPeople.com


Mobile version of this page Mobile version of this page


 

Add links to a text (take II)


add, links, href, addhrefs

10th of November 2004

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="http://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.



Comment

Bob Marley - 27th September 2006  [«« Reply to this]
Hello? people! visit to my site!
 
Name:
Email:
hide my email address.

Your email address will be encoded to prevent email-extraction spiders from reading it so you won't get spammed if you decide to show your email address.