docs: def escape_newlines(s: str) -> str:
      """
      Escapes CR, LF, and backslashes.
  
      Its counterpart is :func:`unescape_newlines`.
  
      ``s.encode("string_escape")`` and ``s.encode("unicode_escape")`` are
      alternatives, but they mess around with quotes, too (specifically,
      backslash-escaping single quotes).
      """
      if not s:
          return s
      s = s.replace("\\", r"\\")  # replace \ with \\
      s = s.replace("\n", r"\n")  # escape \n; note ord("\n") == 10
      s = s.replace("\r", r"\r")  # escape \r; note ord("\r") == 13
      return s