Converting text to html
Robin Munn
rmunn at pobox.com
Fri Apr 4 18:49:03 EST 2003
achrist at easystreet.com <achrist at easystreet.com> wrote:
>
> Is there any recommended code available to convert plain text into
> text that can go into an html document without breaking it? I
> think that I just have to do these three translations:
>
> < => < > => > & => &
>
> But I'm not sure if there are any others. I've got to do this
> quite a bit while the user is waiting, so it would be nice to
> have something that did it in a way that was not a lot slower
> than any of the alternatives.
>
> Surely someone must have cracked this nut sys.maxint times by now.
You want the cgi module, and specifically the cgi.escape() function.
See http://www.python.org/doc/2.2/lib/module-cgi.html and also the
bottom of http://www.python.org/doc/2.2/lib/module-cgi.html for more.
Hope this helps.
--
Robin Munn <rmunn at pobox.com>
http://www.rmunn.com/
PGP key ID: 0x6AFB6838 50FF 2478 CFFB 081A 8338 54F7 845D ACFD 6AFB 6838
More information about the Python-list
mailing list