88
99PAGEFILE = """title: {title}
1010slug: {slug}
11- Template: page
11+ Template: {template}
1212
1313{{% notebook notebooks/{notebook_file} cells[{cells}] %}}
1414"""
@@ -38,7 +38,7 @@ def copy_notebooks():
3838 shutil .copytree (figsource , figdest )
3939
4040 figurelist = os .listdir (abspath_from_here ('content' , 'figures' ))
41- figure_map = {os .path .join ('figures' , fig ) : os .path .join ('/figures' , fig )
41+ figure_map = {os .path .join ('figures' , fig ) : os .path .join ('/PythonDataScienceHandbook/ figures' , fig )
4242 for fig in figurelist }
4343
4444 for nb in nblist :
@@ -50,16 +50,20 @@ def copy_notebooks():
5050
5151 if nb == 'Index.ipynb' :
5252 cells = '1:'
53+ template = 'page'
5354 title = 'Python Data Science Handbook'
5455 else :
5556 cells = '2:'
56- # put nav below title
57+ template = 'booksection'
5758 title = content .cells [2 ].source
5859 if not title .startswith ('#' ) or len (title .splitlines ()) > 1 :
5960 raise ValueError ('title not found in third cell' )
6061 title = title .lstrip ('#' ).strip ()
61- content .cells [1 ], content .cells [2 ] = content .cells [2 ], content .cells [1 ]
6262
63+ # put nav below title
64+ content .cells [0 ], content .cells [1 ], content .cells [2 ] = content .cells [2 ], content .cells [0 ], content .cells [1 ]
65+
66+ # Replace internal URLs and figure links in notebook
6367 for cell in content .cells :
6468 if cell .cell_type == 'markdown' :
6569 for nbname , htmlname in name_map .items ():
@@ -76,6 +80,7 @@ def copy_notebooks():
7680 f .write (PAGEFILE .format (title = title ,
7781 slug = base .lower (),
7882 notebook_file = nb ,
83+ template = template ,
7984 cells = cells ))
8085
8186if __name__ == '__main__' :
0 commit comments