Skip to content

Commit 6587c08

Browse files
committed
optionally allow adding a preamble
1 parent e1b5120 commit 6587c08

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

jupyterlite_sphinx/jupyterlite_sphinx.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,13 @@ def run(self):
816816

817817
if notebook_unique_name is None:
818818
nb = examples_to_notebook(self.content, warning_text=warning_text)
819+
preamble_path = Path("try_examples_preamble.py")
820+
if preamble_path.is_file():
821+
preamble = preamble_path.read_text()
822+
# or raise an error if `preamble` is empty
823+
if preamble:
824+
# insert after the "experimental" warning
825+
nb.cells.insert(1, new_code_cell(preamble))
819826
self.content = None
820827
notebooks_dir = Path(self.env.app.srcdir) / CONTENT_DIR
821828
notebook_unique_name = f"{uuid4()}.ipynb".replace("-", "_")

0 commit comments

Comments
 (0)