[Tutor] Auto-hyperlinking ignoring html tags

Kent Johnson kent37 at tds.net
Sun Nov 26 13:14:36 CET 2006


anil maran wrote:
> Hey
> 
> I m trying to auto-hyperlink urls,
> i found libcia.web.Regextransform.py
> but the problem is it applies auto hyperlink on html tags
> for eg < img src = " http://www.google.com/a.gif " >
> 
> becomes
> *gta* img src=" < a href= "http://www.google.com/a.gif " *lt
> 
> is there any way to auto-hyperlink on text, ignoring whatever is in html 
> tags ie within < >

I'm not sure I understand what you want. I think you have some HTML and 
you want to find URLs that are in the text of the HTML and convert them 
to hyperlinks.

To do this you have to parse the HTML, for example using Beautiful Soup.
http://www.crummy.com/software/BeautifulSoup/

Then you can walk through the parsed tags and modify the text of the 
tags to include the hyperlinks.

Kent



More information about the Tutor mailing list