Browse Source

Add failing testcase for usage of templates as reported by @johnny555 in ipython 3

Benjamin ABEL 9 years ago
parent
commit
54c0cebf83

+ 4 - 1
liquid_tags/notebook.py

@@ -272,7 +272,10 @@ def notebook(preprocessor, tag, markup):
                     {'enabled':True, 'start':start, 'end':end}})
 
     template_file = 'basic'
-    if IPYTHON_VERSION >= 2:
+    if IPYTHON_VERSION >= 3:
+        if os.path.exists('pelicanhtml_3.tpl'):
+            template_file = 'pelicanhtml_3'
+    elif IPYTHON_VERSION == 2:
         if os.path.exists('pelicanhtml_2.tpl'):
             template_file = 'pelicanhtml_2'
     else:

+ 44 - 0
liquid_tags/pelicanhtml_3.tpl

@@ -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 %}
+

+ 1 - 0
liquid_tags/test_data/pelicanhtml_2.tpl

@@ -0,0 +1 @@
+../pelicanhtml_2.tpl

+ 1 - 0
liquid_tags/test_data/pelicanhtml_3.tpl

@@ -0,0 +1 @@
+../pelicanhtml_3.tpl