import nbformatcore
def is_n4l_cell(cell):
"""Pure function to check if cell has n4l marker"""
return (cell.cell_type == 'raw' and
cell.source.strip().startswith('#| n4l'))
def extract_n4l_content(cell):
"""Pure function to extract content without marker"""
lines = cell.source.strip().split('\n')
return '\n'.join(lines[1:]).strip()
def process_notebook(notebook_path):
"""Main processing function using functional composition"""
with open(notebook_path, 'r') as f:
notebook = nbformat.read(f, as_version=4)
# Functional pipeline
return list(map(extract_n4l_content,
filter(is_n4l_cell, notebook.cells)))find_dialog_name
find_dialog_name ()
from ipykernel import get_connection_info# Get full connection details
conn_info = None
try:
conn_info = get_connection_info()
except RuntimeError as e:
print("not running in notebook", e)
conn_infoimport jsonfind_current_notebook
find_current_notebook ()
nb = None
try:
nb = find_current_notebook()
except: pass
nbPath.export_n4l_content
Path.export_n4l_content ()
Add n4l export capability to any Path object
nbsstorytime_export
nbsstorytime_export ()