File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff 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+
278281def 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 )
You can’t perform that action at this time.
0 commit comments