def truncate_string(s, tr):
      """Truncates a string to the first occurrence of any of the terminators.

      Args:
          s: The string to truncate.
          tr: A set of strings representing the terminators.

      Returns:
          The truncated string, or the original string if no terminator is
          found.
      """

      # Find the earliest index where any terminator appears
      earliest_index = len(s)  # Initialize to the end of the string
      for terminator in tr:
        index = s.find(terminator)
        if index != -1 and index < earliest_index:
          earliest_index = index

      # Truncate the string if a terminator was found
      if earliest_index < len(s):
        return s[:earliest_index]
      else:
        return s
Truncates a string to the first occurrence of any of the terminators.

      Args:
          s: The string to truncate.
          tr: A set of strings representing the terminators.

      Returns:
          The truncated string, or the original string if no terminator is
          found.
      
concordia/document/interactive_document.py