From 612fb92dad32049ec4f1b3094b39a712bd9d1e5d 2013-05-27 21:16:28 From: Jonathan Frederic Date: 2013-05-27 21:16:28 Subject: [PATCH] Fixed extract figure, rename from count to index --- diff --git a/nbconvert.py b/nbconvert.py index cf540a8..2f58694 100755 --- a/nbconvert.py +++ b/nbconvert.py @@ -96,7 +96,12 @@ class NbConvertApp(Application): ipynb_file = (self.extra_args)[2] #Export - output, resources, exporter = export_by_name(ipynb_file, export_type) + return_value = export_by_name(ipynb_file, export_type) + if return_value is None: + print("Error: '%s' template not found." % export_type) + return + else: + (output, resources, exporter) = return_value #TODO: Allow user to set output directory and file. destination_filename = None @@ -108,7 +113,7 @@ class NbConvertApp(Application): #be used to create the directory that the files will be exported #into. out_root = ipynb_file[:-6].replace('.', '_').replace(' ', '_') - destination_filename = os.path.join(out_root+'.'+exporter.fileext) + destination_filename = os.path.join(out_root+'.'+exporter.file_extension) destination_directory = out_root+'_files' if not os.path.exists(destination_directory): diff --git a/nbconvert/api/basichtml.py b/nbconvert/api/basichtml.py index f1baaa2..8fd6254 100644 --- a/nbconvert/api/basichtml.py +++ b/nbconvert/api/basichtml.py @@ -29,7 +29,7 @@ class BasicHtmlExporter(exporter.Exporter): """ Exports a basic HTML document. This exporter assists with the export of HTML. Inherit from it if you are writing your own HTML template and need - custom tranformers/filters. If you don't need custom tranformers/ + custom transformers/filters. If you don't need custom transformers/ filters, just change the 'template_file' config option. """ diff --git a/nbconvert/transformers/extractfigure.py b/nbconvert/transformers/extractfigure.py index 16270eb..bfd11c9 100755 --- a/nbconvert/transformers/extractfigure.py +++ b/nbconvert/transformers/extractfigure.py @@ -46,7 +46,7 @@ class ExtractFigureTransformer(ActivatableTransformer): display_data_priority = List(['svg', 'png', 'latex', 'jpg', 'jpeg','text']) #TODO: Change this to .format {} syntax - default_key_template = Unicode('_fig_{count:02d}.{ext}', config=True) + default_key_template = Unicode('_fig_{index:02d}.{ext}', config=True) def cell_transform(self, cell, resources, index): """ @@ -104,9 +104,8 @@ class ExtractFigureTransformer(ActivatableTransformer): ---------- data : str Cell data (from Notebook node cell) - resources : dictionary - Additional resources used in the conversion process. Allows - transformers to pass variables into the Jinja engine. + format : str + Figure format index : int Modified index of the cell being processed (see base.py) """