1313
1414class Converter (converter .BaseConverter ):
1515 accepted_extensions = [".zip" ]
16+ accept_folder = True
1617
1718 def __init__ (self , config ):
1819 super ().__init__ (config )
@@ -135,9 +136,9 @@ def convert_section_and_toc(self, file_or_folder: Path, parent: imf.Notebook):
135136 # HTML -> Markdown
136137 self .convert_section_to_markdown (intermediate_html_folder , parent )
137138
138- def convert_notebook (self ):
139+ def convert_notebook (self , root_path : Path ):
139140 # Only single notebooks can be exported.
140- notebook_path = common .get_single_child_folder (self . root_path )
141+ notebook_path = common .get_single_child_folder (root_path )
141142
142143 root_notebook = imf .Notebook (notebook_path .stem )
143144 self .logger .debug (f'Converting notebook: "{ root_notebook .title } "' )
@@ -155,12 +156,20 @@ def convert_notebook(self):
155156 continue
156157 self .convert_section_and_toc (item , root_notebook )
157158
158- def convert (self , _file_or_folder : Path ):
159+ def convert_file_or_folder (self , file_or_folder : Path ):
160+ if file_or_folder .is_file ():
161+ self .convert_notebook (self .root_path )
162+ else :
163+ for onenote_zip in file_or_folder .glob ("*.zip" ):
164+ root_path = common .extract_zip (onenote_zip )
165+ self .convert_notebook (root_path )
166+
167+ def convert (self , file_or_folder : Path ):
159168 # notebook > section > page
160169 shutil_path = shutil .which ("one2html" )
161170 if shutil_path is None :
162171 self .logger .error ('"one2html" binary not found.' )
163172 return
164173 self .logger .debug (f"Using one2html from: { shutil_path } " )
165174 self .logger .debug (f'temp_folder: "{ self .temp_folder } "' )
166- self .convert_notebook ( )
175+ self .convert_file_or_folder ( file_or_folder )
0 commit comments