Show More
@@ -131,7 +131,7 b' class Exporter(Configurable):' | |||||
131 |
|
131 | |||
132 | default_transformers = List([nbtransformers.coalesce_streams, |
|
132 | default_transformers = List([nbtransformers.coalesce_streams, | |
133 | nbtransformers.SVG2PDFTransformer, |
|
133 | nbtransformers.SVG2PDFTransformer, | |
134 |
nbtransformers.Extract |
|
134 | nbtransformers.ExtractOutputTransformer, | |
135 | nbtransformers.CSSHTMLHeaderTransformer, |
|
135 | nbtransformers.CSSHTMLHeaderTransformer, | |
136 | nbtransformers.RevealHelpTransformer, |
|
136 | nbtransformers.RevealHelpTransformer, | |
137 | nbtransformers.LatexTransformer, |
|
137 | nbtransformers.LatexTransformer, |
@@ -88,7 +88,7 b' class LatexExporter(Exporter):' | |||||
88 | 'NbConvertBase': { |
|
88 | 'NbConvertBase': { | |
89 | 'display_data_priority' : ['latex', 'pdf', 'png', 'jpg', 'svg', 'jpeg', 'text'] |
|
89 | 'display_data_priority' : ['latex', 'pdf', 'png', 'jpg', 'svg', 'jpeg', 'text'] | |
90 | }, |
|
90 | }, | |
91 |
'Extract |
|
91 | 'ExtractOutputTransformer': { | |
92 | 'enabled':True |
|
92 | 'enabled':True | |
93 | }, |
|
93 | }, | |
94 | 'SVG2PDFTransformer': { |
|
94 | 'SVG2PDFTransformer': { |
@@ -37,6 +37,6 b' class RSTExporter(Exporter):' | |||||
37 |
|
37 | |||
38 | @property |
|
38 | @property | |
39 | def default_config(self): |
|
39 | def default_config(self): | |
40 |
c = Config({'Extract |
|
40 | c = Config({'ExtractOutputTransformer':{'enabled':True}}) | |
41 | c.merge(super(RSTExporter,self).default_config) |
|
41 | c.merge(super(RSTExporter,self).default_config) | |
42 | return c |
|
42 | return c |
@@ -47,9 +47,9 b' class TestExporter(ExportersTestsBase):' | |||||
47 |
|
47 | |||
48 | def test_extract_figures(self): |
|
48 | def test_extract_figures(self): | |
49 | """ |
|
49 | """ | |
50 |
If the Extract |
|
50 | If the ExtractOutputTransformer is enabled, are figures extracted? | |
51 | """ |
|
51 | """ | |
52 |
config = Config({'Extract |
|
52 | config = Config({'ExtractOutputTransformer': {'enabled': True}}) | |
53 | exporter = self._make_exporter(config=config) |
|
53 | exporter = self._make_exporter(config=config) | |
54 | (output, resources) = exporter.from_filename(self._get_notebook()) |
|
54 | (output, resources) = exporter.from_filename(self._get_notebook()) | |
55 | assert resources is not None |
|
55 | assert resources is not None |
@@ -2,7 +2,7 b'' | |||||
2 | from .base import Transformer |
|
2 | from .base import Transformer | |
3 | from .convertfigures import ConvertFiguresTransformer |
|
3 | from .convertfigures import ConvertFiguresTransformer | |
4 | from .svg2pdf import SVG2PDFTransformer |
|
4 | from .svg2pdf import SVG2PDFTransformer | |
5 |
from .extract |
|
5 | from .extractoutput import ExtractOutputTransformer | |
6 | from .revealhelp import RevealHelpTransformer |
|
6 | from .revealhelp import RevealHelpTransformer | |
7 | from .latex import LatexTransformer |
|
7 | from .latex import LatexTransformer | |
8 | from .sphinx import SphinxTransformer |
|
8 | from .sphinx import SphinxTransformer |
@@ -1,5 +1,5 b'' | |||||
1 |
"""Module containing a transformer that extracts all of the |
|
1 | """Module containing a transformer that extracts all of the outputs from the | |
2 |
notebook file. The extracted |
|
2 | notebook file. The extracted outputs are returned in the 'resources' dictionary. | |
3 | """ |
|
3 | """ | |
4 | #----------------------------------------------------------------------------- |
|
4 | #----------------------------------------------------------------------------- | |
5 | # Copyright (c) 2013, the IPython Development Team. |
|
5 | # Copyright (c) 2013, the IPython Development Team. | |
@@ -25,10 +25,10 b' from IPython.utils import py3compat' | |||||
25 | # Classes |
|
25 | # Classes | |
26 | #----------------------------------------------------------------------------- |
|
26 | #----------------------------------------------------------------------------- | |
27 |
|
27 | |||
28 |
class Extract |
|
28 | class ExtractOutputTransformer(Transformer): | |
29 | """ |
|
29 | """ | |
30 |
Extracts all of the |
|
30 | Extracts all of the outputs from the notebook file. The extracted | |
31 |
|
|
31 | outputs are returned in the 'resources' dictionary. | |
32 | """ |
|
32 | """ | |
33 |
|
33 | |||
34 | figure_filename_template = Unicode( |
|
34 | figure_filename_template = Unicode( | |
@@ -56,9 +56,9 b' class ExtractFigureTransformer(Transformer):' | |||||
56 | unique_key = resources.get('unique_key', 'figure') |
|
56 | unique_key = resources.get('unique_key', 'figure') | |
57 | output_files_dir = resources.get('output_files_dir', None) |
|
57 | output_files_dir = resources.get('output_files_dir', None) | |
58 |
|
58 | |||
59 |
#Make sure |
|
59 | #Make sure outputs key exists | |
60 |
if not ' |
|
60 | if not 'outputs' in resources: | |
61 |
resources[' |
|
61 | resources['outputs'] = {} | |
62 |
|
62 | |||
63 | #Loop through all of the outputs in the cell |
|
63 | #Loop through all of the outputs in the cell | |
64 | for index, out in enumerate(cell.get('outputs', [])): |
|
64 | for index, out in enumerate(cell.get('outputs', [])): | |
@@ -95,7 +95,7 b' class ExtractFigureTransformer(Transformer):' | |||||
95 | out[out_type + '_filename'] = filename |
|
95 | out[out_type + '_filename'] = filename | |
96 |
|
96 | |||
97 | #In the resources, make the figure available via |
|
97 | #In the resources, make the figure available via | |
98 |
# resources[' |
|
98 | # resources['outputs']['filename'] = data | |
99 |
resources[' |
|
99 | resources['outputs'][filename] = data | |
100 |
|
100 | |||
101 | return cell, resources |
|
101 | return cell, resources |
General Comments 0
You need to be logged in to leave comments.
Login now