code: def safe_quotes(text, escape_single_quotes=False):
      
      if isinstance(text, str):
          safe_text = text.replace('"', "&quot;")
          if escape_single_quotes:
              safe_text = safe_text.replace("'", "&#92;'")
          return safe_text.replace('True', 'true')
      return text
docs: htmlify string