work with IPython 1.x and 2.0
This commit is contained in:
@@ -269,10 +269,13 @@ def notebook(preprocessor, tag, markup):
|
|||||||
'SubCell':
|
'SubCell':
|
||||||
{'enabled':True, 'start':start, 'end':end}})
|
{'enabled':True, 'start':start, 'end':end}})
|
||||||
|
|
||||||
if os.path.exists('pelicanhtml.tpl'):
|
template_file = 'basic'
|
||||||
template_file = 'pelicanhtml'
|
if LooseVersion(IPython.__version__) >= '2.0':
|
||||||
|
if os.path.exists('pelicanhtml_2.tpl'):
|
||||||
|
template_file = 'pelicanhtml_2'
|
||||||
else:
|
else:
|
||||||
template_file = 'basic'
|
if os.path.exists('pelicanhtml_1.tpl'):
|
||||||
|
template_file = 'pelicanhtml_1'
|
||||||
|
|
||||||
if LooseVersion(IPython.__version__) >= '2.0':
|
if LooseVersion(IPython.__version__) >= '2.0':
|
||||||
subcell_kwarg = dict(preprocessors=[SubCell])
|
subcell_kwarg = dict(preprocessors=[SubCell])
|
||||||
@@ -282,7 +285,6 @@ def notebook(preprocessor, tag, markup):
|
|||||||
exporter = HTMLExporter(config=c,
|
exporter = HTMLExporter(config=c,
|
||||||
template_file=template_file,
|
template_file=template_file,
|
||||||
filters={'highlight2html': custom_highlighter},
|
filters={'highlight2html': custom_highlighter},
|
||||||
extra_loaders=[pelican_loader],
|
|
||||||
**subcell_kwarg)
|
**subcell_kwarg)
|
||||||
|
|
||||||
# read and parse the notebook
|
# read and parse the notebook
|
||||||
|
|||||||
@@ -26,18 +26,18 @@
|
|||||||
{% if "# <!-- collapse=True -->" in cell.input %}
|
{% if "# <!-- collapse=True -->" in cell.input %}
|
||||||
<div class="collapseheader box-flex1"><span style="font-weight: bold;">Expand Code</span>
|
<div class="collapseheader box-flex1"><span style="font-weight: bold;">Expand Code</span>
|
||||||
<div class="input_area box-flex1" style="display:none">
|
<div class="input_area box-flex1" style="display:none">
|
||||||
{{ cell.input.replace("# <!-- collapse=True -->\n", "") | highlight2html }}
|
{{ cell.input.replace("# <!-- collapse=True -->\n", "") | highlight2html(metadata=cell.metadata) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% elif "# <!-- collapse=False -->" in cell.input %}
|
{% elif "# <!-- collapse=False -->" in cell.input %}
|
||||||
<div class="collapseheader box-flex1"><span style="font-weight: bold;">Collapse Code</span>
|
<div class="collapseheader box-flex1"><span style="font-weight: bold;">Collapse Code</span>
|
||||||
<div class="input_area box-flex1">
|
<div class="input_area box-flex1">
|
||||||
{{ cell.input.replace("# <!-- collapse=False -->\n", "") | highlight2html }}
|
{{ cell.input.replace("# <!-- collapse=False -->\n", "") | highlight2html(metadata=cell.metadata) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="input_area box-flex1">
|
<div class="input_area box-flex1">
|
||||||
{{ cell.input | highlight2html }}
|
{{ cell.input | highlight2html(metadata=cell.metadata) }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- endblock input %}
|
{%- endblock input %}
|
||||||
44
liquid_tags/pelicanhtml_2.tpl
Normal file
44
liquid_tags/pelicanhtml_2.tpl
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
{%- extends 'basic.tpl' -%}
|
||||||
|
|
||||||
|
{% block stream_stdout -%}
|
||||||
|
<div class="box-flex1 output_subarea output_stream output_stdout">
|
||||||
|
<pre class="ipynb">{{output.text |ansi2html}}</pre>
|
||||||
|
</div>
|
||||||
|
{%- endblock stream_stdout %}
|
||||||
|
|
||||||
|
{% block stream_stderr -%}
|
||||||
|
<div class="box-flex1 output_subarea output_stream output_stderr">
|
||||||
|
<pre class="ipynb">{{output.text |ansi2html}}</pre>
|
||||||
|
</div>
|
||||||
|
{%- endblock stream_stderr %}
|
||||||
|
|
||||||
|
{% block pyerr -%}
|
||||||
|
<div class="box-flex1 output_subarea output_pyerr">
|
||||||
|
<pre class="ipynb">{{super()}}</pre>
|
||||||
|
</div>
|
||||||
|
{%- endblock pyerr %}
|
||||||
|
|
||||||
|
{%- block data_text %}
|
||||||
|
<pre class="ipynb">{{output.text | ansi2html}}</pre>
|
||||||
|
{%- endblock -%}
|
||||||
|
|
||||||
|
{% block input %}
|
||||||
|
{% if "# <!-- collapse=True -->" in cell.input %}
|
||||||
|
<div class="collapseheader box-flex1"><span style="font-weight: bold;">Expand Code</span>
|
||||||
|
<div class="input_area box-flex1" style="display:none">
|
||||||
|
{{ cell.input.replace("# <!-- collapse=True -->\n", "") | highlight2html(metadata=cell.metadata) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% elif "# <!-- collapse=False -->" in cell.input %}
|
||||||
|
<div class="collapseheader box-flex1"><span style="font-weight: bold;">Collapse Code</span>
|
||||||
|
<div class="input_area box-flex1">
|
||||||
|
{{ cell.input.replace("# <!-- collapse=False -->\n", "") | highlight2html(metadata=cell.metadata) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="input_area box-flex1">
|
||||||
|
{{ cell.input | highlight2html(metadata=cell.metadata) }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{%- endblock input %}
|
||||||
|
|
||||||
Reference in New Issue
Block a user