diff --git a/liquid_tags/notebook.py b/liquid_tags/notebook.py index 54b4aa2..1208f1e 100644 --- a/liquid_tags/notebook.py +++ b/liquid_tags/notebook.py @@ -269,11 +269,14 @@ def notebook(preprocessor, tag, markup): 'SubCell': {'enabled':True, 'start':start, 'end':end}}) - if os.path.exists('pelicanhtml.tpl'): - template_file = 'pelicanhtml' + template_file = 'basic' + if LooseVersion(IPython.__version__) >= '2.0': + if os.path.exists('pelicanhtml_2.tpl'): + template_file = 'pelicanhtml_2' else: - template_file = 'basic' - + if os.path.exists('pelicanhtml_1.tpl'): + template_file = 'pelicanhtml_1' + if LooseVersion(IPython.__version__) >= '2.0': subcell_kwarg = dict(preprocessors=[SubCell]) else: @@ -282,7 +285,6 @@ def notebook(preprocessor, tag, markup): exporter = HTMLExporter(config=c, template_file=template_file, filters={'highlight2html': custom_highlighter}, - extra_loaders=[pelican_loader], **subcell_kwarg) # read and parse the notebook diff --git a/liquid_tags/pelicanhtml.tpl b/liquid_tags/pelicanhtml_1.tpl similarity index 90% rename from liquid_tags/pelicanhtml.tpl rename to liquid_tags/pelicanhtml_1.tpl index b32a52b..e0094f3 100644 --- a/liquid_tags/pelicanhtml.tpl +++ b/liquid_tags/pelicanhtml_1.tpl @@ -26,18 +26,18 @@ {% if "# " in cell.input %}
Expand Code
{% elif "# " in cell.input %}
Collapse Code
-{{ cell.input.replace("# \n", "") | highlight2html }} +{{ cell.input.replace("# \n", "") | highlight2html(metadata=cell.metadata) }}
{% else %}
-{{ cell.input | highlight2html }} +{{ cell.input | highlight2html(metadata=cell.metadata) }}
{% endif %} {%- endblock input %} diff --git a/liquid_tags/pelicanhtml_2.tpl b/liquid_tags/pelicanhtml_2.tpl new file mode 100644 index 0000000..937c383 --- /dev/null +++ b/liquid_tags/pelicanhtml_2.tpl @@ -0,0 +1,44 @@ +{%- extends 'basic.tpl' -%} + +{% block stream_stdout -%} +
+
{{output.text |ansi2html}}
+
+{%- endblock stream_stdout %} + +{% block stream_stderr -%} +
+
{{output.text |ansi2html}}
+
+{%- endblock stream_stderr %} + +{% block pyerr -%} +
+
{{super()}}
+
+{%- endblock pyerr %} + +{%- block data_text %} +
{{output.text | ansi2html}}
+{%- endblock -%} + +{% block input %} +{% if "# " in cell.input %} +
Expand Code + +
+{% elif "# " in cell.input %} +
Collapse Code +
+{{ cell.input.replace("# \n", "") | highlight2html(metadata=cell.metadata) }} +
+
+{% else %} +
+{{ cell.input | highlight2html(metadata=cell.metadata) }} +
+{% endif %} +{%- endblock input %} +