code: def escape(string, quote=False):
      
      if string is None:
          return ''
      elif hasattr(string, '__html__'):
          return unicode(string)
      string = string.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
      if quote:
          string = string.replace('"', "&quot;")
      return string
docs: Standard HTML text escaping, but protecting against the agressive
      behavior of Jinja 2 `Markup` and the like.