##// END OF EJS Templates
Fix svg2pdf filter
Thomas Kluyver -
Show More
@@ -47,18 +47,12 b' class ConvertFiguresPreprocessor(Preprocessor):'
47 """
47 """
48
48
49 # Loop through all of the datatypes of the outputs in the cell.
49 # Loop through all of the datatypes of the outputs in the cell.
50 for index, cell_out in enumerate(cell.get('outputs', [])):
50 for output in cell.get('outputs', []):
51 for data_type, data in list(cell_out.items()):
51 if output.output_type in {'execute_result', 'display_data'} \
52 # this must run *before* extract outputs,
52 and self.from_format in output.data \
53 # so figure_name and filename do not exist
53 and self.to_format not in output.data:
54 self._convert_figure(cell_out, resources, data_type, data)
55 return cell, resources
56
54
55 output.data[self.to_format] = self.convert_figure(
56 self.from_format, output.data[self.from_format])
57
57
58 def _convert_figure(self, cell_out, resources, data_type, data):
58 return cell, resources
59 """
60 Convert a figure and output the results to the cell output
61 """
62 if not self.to_format in cell_out and data_type == self.from_format:
63 data = self.convert_figure(data_type, data)
64 cell_out[self.to_format] = data
@@ -61,7 +61,7 b' class SVG2PDFPreprocessor(ConvertFiguresPreprocessor):'
61 with TemporaryDirectory() as tmpdir:
61 with TemporaryDirectory() as tmpdir:
62
62
63 #Write fig to temp file
63 #Write fig to temp file
64 input_filename = os.path.join(tmpdir, 'figure.' + data_format)
64 input_filename = os.path.join(tmpdir, 'figure.svg')
65 # SVG data is unicode text
65 # SVG data is unicode text
66 with io.open(input_filename, 'w', encoding='utf8') as f:
66 with io.open(input_filename, 'w', encoding='utf8') as f:
67 f.write(data)
67 f.write(data)
General Comments 0
You need to be logged in to leave comments. Login now