MCPcopy Create free account
hub / github.com/webpy/webpy / htmlquote

Function htmlquote

web/net.py:219–231  ·  view source on GitHub ↗

r""" Encodes `text` for raw use in HTML. >>> htmlquote(u"<'&\">") u'&lt;&#39;&amp;&quot;&gt;'

(text)

Source from the content-addressed store, hash-verified

217
218
219def htmlquote(text):
220 r"""
221 Encodes `text` for raw use in HTML.
222
223 >>> htmlquote(u"<'&\">")
224 u'&lt;&#39;&amp;&quot;&gt;'
225 """
226 text = text.replace("&", "&amp;") # Must be done first!
227 text = text.replace("<", "&lt;")
228 text = text.replace(">", "&gt;")
229 text = text.replace("'", "&#39;")
230 text = text.replace('"', "&quot;")
231 return text
232
233
234def htmlunquote(text):

Callers 1

websafeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected