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