diff --git a/converters/transformers.py b/converters/transformers.py index 3ddc3fa..770700b 100755 --- a/converters/transformers.py +++ b/converters/transformers.py @@ -82,8 +82,7 @@ def coalesce_streams(cell, other, count): TODO: handle \r deletion """ - - outputs = cell.get('outputs', None) + outputs = cell.get('outputs', []) if not outputs: return cell, other new_outputs = [] @@ -102,7 +101,6 @@ def coalesce_streams(cell, other, count): return cell, other -# todo, make the key part configurable. class ExtractFigureTransformer(ActivatableTransformer): @@ -125,9 +123,12 @@ class ExtractFigureTransformer(ActivatableTransformer): config=True, ) + figname_format_map = Dict({}, + config=True, + ) #to do change this to .format {} syntax - default_key_tpl = Unicode('_fig_%02i.%s', config=True) + default_key_tpl = Unicode('_fig_{count:02d}.{ext}', config=True) def _get_ext(self, ext): if ext in self.extra_ext_map : @@ -137,11 +138,13 @@ class ExtractFigureTransformer(ActivatableTransformer): def _new_figure(self, data, fmt, count): """Create a new figure file in the given format. - Returns a path relative to the input file. """ - tpl = self.key_format_map.get(fmt,self.default_key_tpl) - figname = tpl % (count, self._get_ext(fmt)) - key = tpl % (count, fmt) + tplf = self.figname_format_map.get(fmt,self.default_key_tpl) + tplk = self.key_format_map.get(fmt,self.default_key_tpl) + + # option to pass the hash as data ? + figname = tplf.format(count=count, ext=self._get_ext(fmt)) + key = tplk.format(count=count, ext=self._get_ext(fmt)) # Binary files are base64-encoded, SVG is already XML if fmt in ('png', 'jpg', 'pdf'): diff --git a/tests/template_ref/00_notebook_tour_orig.html b/tests/template_ref/00_notebook_tour_orig.html index 8e858ec..e8a68aa 100644 --- a/tests/template_ref/00_notebook_tour_orig.html +++ b/tests/template_ref/00_notebook_tour_orig.html @@ -1797,42 +1797,7 @@ it will automatically invoke a pager at the bottom of the screen:

-
0 
-
-
-
-
-
1 
-
-
-
-
-
2 
-
-
-
-
-
3 
-
-
-
-
-
4 
-
-
-
-
-
5 
-
-
-
-
-
6 
-
-
-
-
-
7
+
0 1 2 3 4 5 6 7
 
@@ -4303,4 +4268,4 @@ X07vG9Z4QUTEBQ4dOkRpaSklJSVnnQPx/xV9BfkfDyZLAAAAAElFTkSuQmCC - \ No newline at end of file + diff --git a/tests/template_ref/00_notebook_tour_orig.rst b/tests/template_ref/00_notebook_tour_orig.rst index aa558bf..0c198f6 100644 --- a/tests/template_ref/00_notebook_tour_orig.rst +++ b/tests/template_ref/00_notebook_tour_orig.rst @@ -167,36 +167,7 @@ In[19]: .. parsed-literal:: - 0 - -.. parsed-literal:: - - 1 - -.. parsed-literal:: - - 2 - -.. parsed-literal:: - - 3 - -.. parsed-literal:: - - 4 - -.. parsed-literal:: - - 5 - -.. parsed-literal:: - - 6 - -.. parsed-literal:: - - 7 - + 0 1 2 3 4 5 6 7 Clean crash and restart ----------------------- diff --git a/tests/template_ref/00_notebook_tour_orig.tex b/tests/template_ref/00_notebook_tour_orig.tex index 3608916..704bc01 100644 --- a/tests/template_ref/00_notebook_tour_orig.tex +++ b/tests/template_ref/00_notebook_tour_orig.tex @@ -316,36 +316,7 @@ for i in range(8): \begin{codeoutput} \begin{verbatim} -0 -\end{verbatim} - -\begin{verbatim} -1 -\end{verbatim} - -\begin{verbatim} -2 -\end{verbatim} - -\begin{verbatim} -3 -\end{verbatim} - -\begin{verbatim} -4 -\end{verbatim} - -\begin{verbatim} -5 -\end{verbatim} - -\begin{verbatim} -6 -\end{verbatim} - -\begin{verbatim} -7 - +0 1 2 3 4 5 6 7 \end{verbatim} \end{codeoutput}