class_docstr: A class that can read or write a Jupyter notebook as text
class_docstr_tok: ["A","class","that","can","read","or","write","a","Jupyter","notebook","as","text"]
docstr: Read a notebook represented as text
docstr_tok: ["Read","a","notebook","represented","as","text"]
code: def reads(self, s, **_):
      """Read a notebook represented as text"""
      if self.fmt.get("format_name") == "pandoc":
          return md_to_notebook(s)
  
      if self.fmt.get("format_name") == "quarto":
          return qmd_to_notebook(s)
  
      if self.fmt.get("format_name") == MYST_FORMAT_NAME:
          return myst_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.header_suffix,
          self.implementation.extension,
          self.fmt.get(
              "root_level_metadata_as_raw_cell",
              self.config.root_level_metadata_as_raw_cell
              if self.config is not None
              else True,
          ),
      )
      default_language = default_language_from_metadata_and_ext(
          metadata, self.implementation.extension
      )
      self.update_fmt_with_notebook_options(metadata, read=True)
  
      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_json = False
  
      while lines:
          reader = self.implementation.cell_reader_class(
              self.fmt, default_language
          )
          cell, pos = reader.read(lines)
          cells.append(cell)
          cell_metadata_json = (
              cell_metadata_json or reader.cell_metadata_json
          )
          if pos <= 0:
              raise Exception(
                  "Blocked at lines " + "\n".join(lines[:6])
              )  # pragma: no cover
          lines = lines[pos:]
  
      custom_cell_magics = self.fmt.get("custom_cell_magics", "").split(
          ","
      )
      set_main_and_cell_language(
          metadata,
          cells,
          self.implementation.extension,
          custom_cell_magics,
      )
      cell_metadata = set()
      for cell in cells:
          cell_metadata.update(cell.metadata.keys())
      update_metadata_filters(metadata, jupyter_md, cell_metadata)
  
      if cell_metadata_json:
          metadata.setdefault("jupytext", {}).setdefault(
              "cell_metadata_json", True
          )
  
      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)
  
imports: import logging
  import os
  import sys
  import warnings
  from copy import copy, deepcopy
  import nbformat
  from nbformat.v4.nbbase import NotebookNode, new_code_cell, new_notebook
  from nbformat.v4.rwbase import NotebookReader, NotebookWriter
  from .cell_metadata import _IGNORE_CELL_METADATA
  from .formats import _VALID_FORMAT_OPTIONS, divine_format, format_name_for_ext, get_format_implementation, guess_format, long_form_one_format, read_format_from_metadata, rearrange_jupytext_metadata, update_jupytext_formats_metadata
  from .header import encoding_and_executable, header_to_metadata_and_cell, insert_jupytext_info_and_filter_metadata, insert_or_test_version_number, metadata_and_cell_to_header
  from .languages import default_language_from_metadata_and_ext, set_main_and_cell_language
  from .metadata_filter import filter_metadata, update_metadata_filters
  from .myst import MYST_FORMAT_NAME, myst_extensions, myst_to_notebook, notebook_to_myst
  from .pandoc import md_to_notebook, notebook_to_md
  from .pep8 import pep8_lines_between_cells
  from .quarto import notebook_to_qmd, qmd_to_notebook
  from .version import __version__
label_desc: Use image node_id 3 for calling the TextNotebookConverter obj's underlying member method code with example usage: obj.reads(s) and returns: new_notebook, md_to_notebook, qmd_to_notebook, myst_to_notebook