docs: def _find_spellcheckable_chunks(contents,
                                  comment_system):
      """Given some contents for a file, find chunks that can be spellchecked.
  
      This applies the following rules:
       1. If the comment system comments individual lines, that whole line
          can be spellchecked from the point of the comment
       2. If a comment-start marker or triple quote is found, keep going
          until a comment end marker or matching triple quote is found.
       3. In both cases, ignore anything in triple backticks.
      """
      state = InTextParser()
      comment_system_transitions = CommentSystemTransitions(comment_system)
  
      chunks = []
      for line_index, line in enumerate(contents):
          column = 0
          line_len = len(line)
          escape_next = False
  
          # We hit a new line. If we were waiting until the end of the line
          # then add a new chunk in here
          (state,
           column_delta,
           chunk_info) = state.get_transition(line,
                                              line_index,
                                              0,
                                              False,
                                              comment_system_transitions)
          _maybe_append_chunk(chunk_info,
                              line_index - 1,
                              len(contents[line_index - 1]),
                              contents,
                              chunks)
          column += column_delta
  
          while column < line_len:
              # Check if the next character should be considered as escaped. That
              # only happens if we are not escaped and the current character is
              # a backslash.
              is_escaped = escape_next
              escape_next = not is_escaped and line[column] == "\\"
  
              (state,
               column_delta,
               chunk_info) = state.get_transition(line,
                                                  line_index,
                                                  column,
                                                  is_escaped,
                                                  comment_system_transitions)
  
              _maybe_append_chunk(chunk_info,
                                  line_index,
                                  column,
                                  contents,
                                  chunks)
              column += column_delta
  
      last_line_index = len(contents) - 1
      (state,
       column_delta,
       chunk_info) = state.get_transition(contents[-1],
                                          last_line_index,
                                          len(contents[-1]),
                                          False,
                                          comment_system_transitions,
                                          eof=True)
      _maybe_append_chunk(chunk_info,
                          last_line_index,
                          len(contents[last_line_index]),
                          contents,
                          chunks)
  
      return chunks