# notebook

URL: /patitas/api/notebook/
Section: api
Description: Jupyter notebook (.ipynb) parser for Patitas.

Parses nbformat 4.x JSON to (markdown_content, metadata) in the same shape
as Markdown files with frontmatter. Zero dependencies — uses stdlib json only.

---

> For a complete page index, fetch /patitas/llms.txt.

Open LLM text
(/patitas/api/notebook/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fnotebook%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fnotebook%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fnotebook%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fnotebook%2Findex.txt)

Module

#
`notebook`

Jupyter notebook (.ipynb) parser for Patitas.

Parses nbformat 4.x JSON to (markdown_content, metadata) in the same shape
as Markdown files with frontmatter. Zero dependencies — uses stdlib json only.

6Functions

## Functions

`parse_notebook`

2

`tuple[str, dict[str, Any…`

▼

Parse a Jupyter notebook (.ipynb) to Markdown content and metadata.

`def parse_notebook(content: str, source_path: Path | str | None = None) -> tuple[str, dict[str, Any]]`

##### Parameters

Name
Type
Description

`content`
`str`

Raw JSON content of the .ipynb file (caller handles I/O)

`source_path`
`Path | str | None`

Optional path for title fallback when notebook has no title

Default:`None`

##### Returns

`tuple[str, dict[str, Any]]`

`_extract_metadata`

2

`dict[str, Any]`

▼

Extract metadata from notebook for frontmatter-like use.

`def _extract_metadata(nb: dict[str, Any], source_path: Path | str | None) -> dict[str, Any]`

##### Parameters

Name
Type
Description

`nb`
`dict[str, Any]`

`source_path`
`Path | str | None`

##### Returns

`dict[str, Any]`

`_cells_to_markdown`

1

`str`

▼

Convert notebook cells to Markdown string.

`def _cells_to_markdown(nb: dict[str, Any]) -> str`

##### Parameters

Name
Type
Description

`nb`
`dict[str, Any]`

##### Returns

`str`

`_output_to_markdown`

1

`str`

▼

Convert a single output to Markdown/HTML.

`def _output_to_markdown(output: dict[str, Any]) -> str`

##### Parameters

Name
Type
Description

`output`
`dict[str, Any]`

##### Returns

`str`

`_infer_code_language`

1

`str`

▼

Infer language for code cell from metadata.

`def _infer_code_language(cell: dict[str, Any]) -> str`

##### Parameters

Name
Type
Description

`cell`
`dict[str, Any]`

##### Returns

`str`

`_escape_html`

1

`str`

▼

Escape HTML special characters.

`def _escape_html(text: str) -> str`

##### Parameters

Name
Type
Description

`text`
`str`

##### Returns

`str`
