Show More
@@ -33,16 +33,21 b' class ConverterPy(Converter):' | |||||
33 | return ['#{0} {1}'.format('#'*cell.level, cell.source), ''] |
|
33 | return ['#{0} {1}'.format('#'*cell.level, cell.source), ''] | |
34 |
|
34 | |||
35 | def render_code(self, cell): |
|
35 | def render_code(self, cell): | |
|
36 | try: | |||
|
37 | prompt_number = cell.prompt_number | |||
|
38 | except AttributeError: | |||
|
39 | prompt_number = " " | |||
|
40 | ||||
36 | if not cell.input: |
|
41 | if not cell.input: | |
37 | return [] |
|
42 | return [] | |
38 | lines = [] |
|
43 | lines = [] | |
39 | if self.show_prompts: |
|
44 | if self.show_prompts: | |
40 |
lines.extend(['# In[%s]:' % |
|
45 | lines.extend(['# In[%s]:' % prompt_number]) | |
41 | src = cell.input |
|
46 | src = cell.input | |
42 | lines.extend([src, '']) |
|
47 | lines.extend([src, '']) | |
43 | if self.show_output: |
|
48 | if self.show_output: | |
44 | if cell.outputs : |
|
49 | if cell.outputs : | |
45 |
lines.extend(['# Out[%s]:' % |
|
50 | lines.extend(['# Out[%s]:' % prompt_number]) | |
46 | for output in cell.outputs: |
|
51 | for output in cell.outputs: | |
47 | conv_fn = self.dispatch(output.output_type) |
|
52 | conv_fn = self.dispatch(output.output_type) | |
48 | lines.extend(conv_fn(output)) |
|
53 | lines.extend(conv_fn(output)) |
@@ -11,10 +11,16 b' class ConverterRST(Converter):' | |||||
11 | return ['{0}\n{1}\n'.format(cell.source, marker * len(cell.source))] |
|
11 | return ['{0}\n{1}\n'.format(cell.source, marker * len(cell.source))] | |
12 |
|
12 | |||
13 | def render_code(self, cell): |
|
13 | def render_code(self, cell): | |
|
14 | # Note: cell has type 'IPython.nbformat.v3.nbbase.NotebookNode' | |||
14 | if not cell.input: |
|
15 | if not cell.input: | |
15 | return [] |
|
16 | return [] | |
16 |
|
17 | |||
17 | lines = ['In[%s]:' % cell.prompt_number, ''] |
|
18 | try: | |
|
19 | prompt_number = cell.prompt_number | |||
|
20 | except AttributeError: | |||
|
21 | prompt_number = " " | |||
|
22 | ||||
|
23 | lines = ['In[%s]:' % prompt_number, ''] | |||
18 | lines.extend(rst_directive('.. code:: python', cell.input)) |
|
24 | lines.extend(rst_directive('.. code:: python', cell.input)) | |
19 |
|
25 | |||
20 | for output in cell.outputs: |
|
26 | for output in cell.outputs: |
General Comments 0
You need to be logged in to leave comments.
Login now