Htmlizing text
William Park
parkw at better.net
Mon Nov 29 17:07:05 EST 1999
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.
More information about the Python-list
mailing list