Htmlizing text

phil hunt philh at vision25.demon.co.uk
Tue Nov 30 02:26:17 CET 1999


On Mon, 29 Nov 1999, William Park wrote:

> On Mon, Nov 29, 1999 at 09:03:46PM +0000, Phil Hunt wrote:
> > 
> > Is there a function in the standard Python library to HTML-ize text,
> > i.e. to replace 'a > b & c < d' with 'a > b & c < d'?
> > 
> > (I realize this can be done with regular expressions, but is there
> > an easy way?)
> > 
> > -- 
> > Phil Hunt - - - phil at comuno.com
> 
> The following function replaces [<&>] unconditionally.
>     def escapeall(s):
> 	s = string.replace(s, '&', '&')		# do this first
> 	s = string.replace(s, '<', '<')
> 	s = string.replace(s, '>', '>')
> 	return s
> I used this in my 'HTMLtag' module which generates HTML tags.
> 
> William.
> 


Thanks.

-- 
***** Phil Hunt ***** send email to phil at comuno.com *****
Moore's Law: hardware speed doubles every 18 months
Gates' Law: software speed halves every 18 months 
































More information about the Python-list mailing list