Parser#

(nbrefactor.processor.parser)

Parsing methods for both code and markdown cells in a notebook

parse_code_cell(cell_idx, source, module_node)[source]#

Parses a code cell into a ParsedCodeCell object.

Parameters:
  • cell_idx (int) – index of the cell in the notebook.

  • source (str) – the cell’s index in the notebook.

  • module_node (ModuleNode) – the module node in the built module tree

Returns:

a parsed code cell object with analyzed imports, definitions, usages, etc.

Return type:

ParsedCodeCell

parse_markdown_cell(cell_idx, source)[source]#

Parses a markdown cell into a ParsedMarkdownCell object.

Parameters:
  • cell_idx (int) – the cell’s index in the notebook.

  • source (str) – the cell’s markdown content.

Returns:

A parsed markdown cell object containing headers and commands.

Return type:

ParsedMarkdownCell