docs: def wrap(self, text):
          '''Wraps the text object to width, breaking at whitespaces. Runs of
          whitespace characters are preserved, provided they do not fall at a
          line boundary. The implementation is based on that of textwrap from the
          standard library, but we can cope with StringWithFormatting objects.
  
          :returns: a list of string-like objects.
          '''
          result = []
          chunks = self._chunk(text)
          while chunks:
              self._lstrip(chunks)
              current_line = []
              current_line_length = 0
              current_chunk_length = 0
              while chunks:
                  current_chunk_length = len(chunks[0])
                  if current_line_length + current_chunk_length <= self.width:
                      current_line.append(chunks.pop(0))
                      current_line_length += current_chunk_length
                  else:
                      # Line is full
                      break
              # Handle case where chunk is bigger than an entire line
              if current_chunk_length > self.width:
                  space_left = self.width - current_line_length
                  current_line.append(chunks[0][:space_left])
                  chunks[0] = chunks[0][space_left:]
              self._rstrip(current_line)
              if current_line:
                  result.append(reduce(
                      lambda x, y: x + y, current_line[1:], current_line[0]))
              else:
                  # FIXME: should this line go? Removing it makes at least simple
                  # cases like wrap('    ', 10) actually behave like
                  # textwrap.wrap...
                  result.append('')
          return result