code: def code_to_text(self):
          
          active = is_active(self.ext, self.metadata)
          if self.language != self.default_language and 'active' not in self.metadata:
              active = False
  
          source = copy(self.source)
          escape_code_start(source, self.ext, self.language)
  
          if active:
              comment_magic(source, self.language, self.comment_magics)
          else:
              source = [self.comment + ' ' + line if line else self.comment for line in source]
  
          if self.explicit_start_marker(source):
              self.metadata['endofcell'] = self.cell_marker_end or endofcell_marker(source, self.comment)
  
          if not self.metadata or not self.use_cell_markers:
              return source
  
          lines = []
          endofcell = self.metadata['endofcell']
          if endofcell == '-' or self.cell_marker_end:
              del self.metadata['endofcell']
  
          cell_start = [self.comment, self.cell_marker_start or '+']
          if not self.cell_marker_start:
              cell_start.append(metadata_to_json_options(self.metadata))
          elif self.metadata:
              if 'title' in self.metadata:
                  cell_start.append(self.metadata.pop('title'))
              if self.metadata:
                  cell_start.append(metadata_to_json_options(self.metadata))
  
          lines.append(' '.join(cell_start))
          lines.extend(source)
          lines.append(self.comment + ' {}'.format(endofcell))
          return lines
docs: Return the text representation of a code cell