docs: def escape(s, quote=False):
      """Replace special characters "&", "<" and ">" to HTML-safe sequences.  If
      the optional flag `quote` is `True`, the quotation mark character is
      also translated.
  
      There is a special handling for `None` which escapes to an empty string.
  
      :param s: the string to escape.
      :param quote: set to true to also escape double quotes.
      """
      if s is None:
          return ''
      if hasattr(s, '__html__'):
          return s.__html__()
      if not isinstance(s, (text_type, binary_type)):
          s = text_type(s)
      if isinstance(s, binary_type):
          try:
              s.decode('ascii')
          except:
              s = s.decode('utf-8', 'replace')
      s = s.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
      if quote:
          s = s.replace('"', "&quot;")
      return s