Kaydet (Commit) 64c66209 authored tarafından Guido van Rossum's avatar Guido van Rossum

Add optional 'quote' flag argument to escape(); if true, translate '"'

to '"'.
üst 1e8c8a20
......@@ -1316,12 +1316,14 @@ environment as well. Here are some common variable names:
# Utilities
# =========
def escape(s):
def escape(s, quote=None):
"""Replace special characters '&', '<' and '>' by SGML entities."""
import regsub
s = regsub.gsub("&", "&amp;", s) # Must be done first!
s = regsub.gsub("<", "&lt;", s)
s = regsub.gsub(">", "&gt;", s)
if quote:
s = regsub.gsub('"', "&quot;", s)
return s
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment