Show More
@@ -70,7 +70,7 b' class ConverterTemplate(Configurable):' | |||||
70 | #------------------------------------------------------------------------- |
|
70 | #------------------------------------------------------------------------- | |
71 | infile = Any() |
|
71 | infile = Any() | |
72 |
|
72 | |||
73 |
|
73 | |||
74 | infile_dir = Unicode() |
|
74 | infile_dir = Unicode() | |
75 |
|
75 | |||
76 | def __init__(self, tplfile='fullhtml', config=None, **kw): |
|
76 | def __init__(self, tplfile='fullhtml', config=None, **kw): | |
@@ -87,17 +87,12 b' class ConverterTemplate(Configurable):' | |||||
87 | for worksheet in self.nb.worksheets: |
|
87 | for worksheet in self.nb.worksheets: | |
88 | for cell in worksheet.cells: |
|
88 | for cell in worksheet.cells: | |
89 | cell.type = cell.cell_type |
|
89 | cell.type = cell.cell_type | |
90 |
|
|
90 | converted_cells.append(worksheet) | |
91 | continue |
|
|||
92 | if cell.cell_type in ('code'): |
|
|||
93 | converted_cells.append({'type':'code','source':cell.input}) |
|
|||
94 | else : |
|
|||
95 | converted_cells.append({'type':cell.cell_type,'source': python_comment(cell.source)}) |
|
|||
96 |
|
91 | |||
97 | return converted_cells |
|
92 | return converted_cells | |
98 |
|
93 | |||
99 | def convert(self, cell_separator='\n'): |
|
94 | def convert(self, cell_separator='\n'): | |
100 |
return self.template.render( |
|
95 | return self.template.render(worksheets=self.process()) | |
101 |
|
96 | |||
102 |
|
97 | |||
103 | def read(self, filename): |
|
98 | def read(self, filename): |
@@ -1,25 +1,27 b'' | |||||
1 | {%- block header -%} |
|
1 | {%- block header -%} | |
2 | {%- endblock header -%} |
|
2 | {%- endblock header -%} | |
3 | {%- block body -%} |
|
3 | {%- block body -%} | |
4 |
{%- for |
|
4 | {%- for worksheet in worksheets -%} | |
5 |
{%- |
|
5 | {%- for cell in worksheet.cells -%} | |
6 |
{%- |
|
6 | {%- block any_cell scoped -%} | |
7 |
{%- |
|
7 | {%- if cell.type in ['code'] -%} | |
8 |
{%- |
|
8 | {%- block codecell scoped-%} | |
9 | {%- elif cell.type in ['markdown'] -%} |
|
9 | {%- endblock codecell-%} | |
10 |
{%- |
|
10 | {%- elif cell.type in ['markdown'] -%} | |
11 |
{%- |
|
11 | {%- block markdowncell scoped-%} | |
12 | {%- elif cell.type in ['heading'] -%} |
|
12 | {%- endblock markdowncell -%} | |
13 |
{%- |
|
13 | {%- elif cell.type in ['heading'] -%} | |
14 |
{%- |
|
14 | {%- block headingcell scoped-%} | |
15 | {%- elif cell.type in ['raw'] -%} |
|
15 | {%- endblock headingcell -%} | |
16 |
{%- |
|
16 | {%- elif cell.type in ['raw'] -%} | |
17 |
{%- |
|
17 | {%- block rawcell scoped-%} | |
18 |
{%- e |
|
18 | {%- endblock rawcell -%} | |
19 |
{%- |
|
19 | {%- else -%} | |
20 |
{%- |
|
20 | {%- block unknowncell scoped-%} | |
21 | {%- endif -%} |
|
21 | {%- endblock unknowncell -%} | |
22 | {%- endblock any_cell -%} |
|
22 | {%- endif -%} | |
|
23 | {%- endblock any_cell -%} | |||
|
24 | {%- endfor -%} | |||
23 | {%- endfor -%} |
|
25 | {%- endfor -%} | |
24 | {%- endblock body -%} |
|
26 | {%- endblock body -%} | |
25 |
|
27 |
@@ -40,12 +40,10 b' consider calling super even if block is leave block, we might insert more block ' | |||||
40 | {% endblock pyerr %} |
|
40 | {% endblock pyerr %} | |
41 | {%- endif %} |
|
41 | {%- endif %} | |
42 | {%- endfor -%} |
|
42 | {%- endfor -%} | |
43 | {% endif %} |
|
43 | {% endif -%} | |
|
44 | {%- endblock codecell %} | |||
44 |
|
45 | |||
45 | {% endblock codecell %} |
|
46 | {% block markdowncell scoped %}{% endblock markdowncell %} | |
46 |
|
||||
47 | {% block markdowncell scoped %} |
|
|||
48 | {% endblock markdowncell %} |
|
|||
49 |
|
47 | |||
50 | {% block headingcell scoped %} |
|
48 | {% block headingcell scoped %} | |
51 | {% endblock headingcell %} |
|
49 | {% endblock headingcell %} |
@@ -1,9 +1,31 b'' | |||||
1 | {%- extends 'python.tpl' -%} |
|
1 | {%- extends 'python.tpl' -%} | |
2 |
|
2 | |||
3 | {% block any_cell %} |
|
3 | {#% block any_cell %} | |
4 | ============================== |
|
4 | ============================== | |
5 | =======start {{cell.type}}========= |
|
5 | =======start {{cell.type}}========= | |
6 | {{ super() }} |
|
6 | {{ super() }} | |
7 | ======= end {{cell.type}} ========= |
|
7 | ======= end {{cell.type}} ========= | |
8 | =============================={% endblock any_cell %} |
|
8 | =============================={% endblock any_cell %#} | |
|
9 | ||||
|
10 | ||||
|
11 | ||||
|
12 | {% block markdowncell %}---- Start MD ----{{ super() }} | |||
|
13 | ---- End MD ---- | |||
|
14 | {% endblock markdowncell %} | |||
|
15 | ||||
|
16 | {% block codecell %}---- Start Code ----{{ super() }} | |||
|
17 | ---- End Code ---- | |||
|
18 | {% endblock codecell %} | |||
|
19 | ||||
|
20 | {% block headingcell scoped %}---- Start heading ----{{ super() }} | |||
|
21 | ---- End heading ---- | |||
|
22 | {% endblock headingcell %} | |||
|
23 | ||||
|
24 | {% block rawcell scoped %}---- Start Raw ---- | |||
|
25 | {{ super() }} | |||
|
26 | ---- End Raw ----{% endblock rawcell %} | |||
|
27 | ||||
|
28 | {% block unknowncell scoped %} | |||
|
29 | unknown type {{cell.type}} | |||
|
30 | {% endblock unknowncell %} | |||
9 |
|
31 |
@@ -23,23 +23,9 b'' | |||||
23 | {% block display_data scoped %} |
|
23 | {% block display_data scoped %} | |
24 | # image file:{% endblock display_data %} |
|
24 | # image file:{% endblock display_data %} | |
25 |
|
25 | |||
26 | {# |
|
|||
27 | {% block codecell scoped %} |
|
|||
28 | # In[{{cell.prompt_number if cell.prompt_number else ' '}}]: |
|
|||
29 | {% if cell.outputs %} |
|
|||
30 | {%- for output in cell.outputs -%} |
|
|||
31 | {%- if output.output_type in ['pyout','stream']%} |
|
|||
32 |
|
||||
33 | {%- elif output.output_type in ['display_data'] %} |
|
|||
34 | {{"# image file: fucking display_data"}} |
|
|||
35 | {%- endfor -%} |
|
|||
36 | {% endif %} |
|
|||
37 |
|
||||
38 | {% endblock codecell %} |
|
|||
39 | #} |
|
|||
40 |
|
||||
41 | {% block markdowncell scoped %} |
|
26 | {% block markdowncell scoped %} | |
42 |
{{ cell.source | pycomment |
|
27 | {{ cell.source | pycomment }} | |
|
28 | {% endblock markdowncell %} | |||
43 |
|
29 | |||
44 | {% block headingcell scoped %} |
|
30 | {% block headingcell scoped %} | |
45 | {{ '#' * cell.level }}{{ cell.source | pycomment}} |
|
31 | {{ '#' * cell.level }}{{ cell.source | pycomment}} |
General Comments 0
You need to be logged in to leave comments.
Login now