MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / html_escape

Function html_escape

21-async/mojifinder/bottle.py:2625–2628  ·  view source on GitHub ↗

Escape HTML special characters ``&<>`` and quotes ``'"``.

(string)

Source from the content-addressed store, hash-verified

2623
2624
2625def html_escape(string):
2626 ''' Escape HTML special characters ``&<>`` and quotes ``'"``. ''&#x27;
2627 return string.replace('&','&amp;').replace('<','&lt;').replace('>','&gt;')\
2628 .replace('"','&quot;').replace("'",'&#039;')
2629
2630
2631def html_quote(string):

Callers 2

wsgiMethod · 0.85
html_quoteFunction · 0.85

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected