code: def reads(self, s, **_):
          
          if self.fmt.get('format_name') == 'pandoc':
              return md_to_notebook(s)
  
          lines = s.splitlines()
  
          cells = []
          metadata, jupyter_md, header_cell, pos = header_to_metadata_and_cell(lines,
                                                                               self.implementation.header_prefix,
                                                                               self.implementation.extension)
          default_language = default_language_from_metadata_and_ext(metadata, self.implementation.extension)
          self.update_fmt_with_notebook_options(metadata)
  
          if header_cell:
              cells.append(header_cell)
  
          lines = lines[pos:]
  
          if self.implementation.format_name and self.implementation.format_name.startswith('sphinx'):
              cells.append(new_code_cell(source='%matplotlib inline'))
  
          cell_metadata = set()
  
          while lines:
              reader = self.implementation.cell_reader_class(self.fmt, default_language)
              cell, pos = reader.read(lines)
              cells.append(cell)
              cell_metadata.update(cell.metadata.keys())
              if pos <= 0:
                  raise Exception('Blocked at lines ' + '\n'.join(lines[:6]))  # pragma: no cover
              lines = lines[pos:]
  
          update_metadata_filters(metadata, jupyter_md, cell_metadata)
          set_main_and_cell_language(metadata, cells, self.implementation.extension)
  
          if self.implementation.format_name and self.implementation.format_name.startswith('sphinx'):
              filtered_cells = []
              for i, cell in enumerate(cells):
                  if cell.source == '' and i > 0 and i + 1 < len(cells) \
                          and cells[i - 1].cell_type != 'markdown' and cells[i + 1].cell_type != 'markdown':
                      continue
                  filtered_cells.append(cell)
              cells = filtered_cells
  
          return new_notebook(cells=cells, metadata=metadata)
docs: Read a notebook represented as text