Skip to content

Commit b64fd3e

Browse files
Fix: move synopsis (back) to end
1 parent 70bbaa7 commit b64fd3e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

notebooks/shared/utils/export_notebook_code.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ def get_notebook_synopsis(notebook_name: str,
275275

276276
return title, fix_synopsis(synopsis)
277277

278+
279+
SYNOPSIS_TITLE = "## Synopsis"
280+
278281
def export_notebook_code(notebook_name: str,
279282
project: str = "fuzzingbook",
280283
path: Optional[List[str]] = None) -> None:
@@ -308,8 +311,27 @@ def export_notebook_code(notebook_name: str,
308311

309312
print_utf8(header)
310313
sep = ''
314+
315+
# Move synopsis cells to end
316+
cells = [] # Non-synopsis cells
317+
synopsis_cells = [] # Cells of the (last) synopsis
311318

319+
in_synopsis = False
312320
for cell in notebook.cells:
321+
if cell.source.startswith(SYNOPSIS_TITLE):
322+
in_synopsis = True
323+
synopsis_cells = []
324+
elif cell.source.startswith("## "):
325+
in_synopsis = False
326+
327+
if in_synopsis:
328+
synopsis_cells.append(cell)
329+
else:
330+
cells.append(cell)
331+
332+
cells += synopsis_cells
333+
334+
for cell in cells:
313335
if cell.cell_type == 'code':
314336
code = cell.source
315337
match_code = RE_CODE.match(code)

0 commit comments

Comments
 (0)