Debian Codegraph @

Cheetah/Utils/htmlEncode.py

raw symbols SCIP
1 """This is a copy of the htmlEncode function in Webware.
2
3
4 @@TR: It implemented more efficiently.
5
6 """
7 htmlCodes = [
8 ['&', '&'],
9 ['<', '&lt;'],
10 ['>', '&gt;'],
11 ['"', '&quot;'],
12 ]
13 htmlCodesReversed = htmlCodes[:]
14 htmlCodesReversed.reverse()
15
16
17 def htmlEncode(s, codes=htmlCodes):
18 """ Returns the HTML encoded version of the given string. This is useful to
19 display a plain ASCII text string on a web page."""
20 for code in codes:
21 s = s.replace(code[0], code[1])
22 return s