all2md.parsers.ipynb

Jupyter Notebook to AST converter.

This module provides conversion from Jupyter Notebooks to AST representation. It replaces direct markdown string generation with structured AST building.

class all2md.parsers.ipynb.IpynbToAstConverter

Bases: BaseParser

Convert Jupyter Notebooks to AST representation.

This converter processes notebook JSON and builds an AST that can be rendered to various markdown flavors.

Parameters:

options (IpynbOptions or None) – Conversion options

Initialize the IPYNB parser with options and progress callback.

__init__(options: IpynbOptions | None = None, progress_callback: Callable[[ProgressEvent], None] | None = None)

Initialize the IPYNB parser with options and progress callback.

parse(input_data: str | Path | IO[bytes] | bytes) Document

Parse Jupyter Notebook input into an AST.

Parameters:

input_data (str, Path, IO[bytes], or bytes) – The input notebook to parse

Returns:

AST Document node

Return type:

Document

Raises:
convert_to_ast(notebook: dict, language: str) Document

Convert notebook to AST Document.

Returns:

AST document node

Return type:

Document

extract_metadata(document: Any) DocumentMetadata

Extract metadata from Jupyter notebook.

Parameters:

document (dict) – Parsed notebook JSON structure

Returns:

Extracted metadata

Return type:

DocumentMetadata