diff --git a/converters/template.py b/converters/template.py index aae868d..b53fba8 100755 --- a/converters/template.py +++ b/converters/template.py @@ -40,7 +40,7 @@ from IPython.utils.traitlets import (List, Unicode, Type, Bool, Dict, CaselessSt from IPython.utils.text import indent from .utils import remove_ansi from markdown import markdown -from .utils import highlight +from .utils import highlight,ansi2html #----------------------------------------------------------------------------- # Class declarations #----------------------------------------------------------------------------- @@ -60,6 +60,7 @@ env.filters['rm_fake'] = rm_fake env.filters['rm_ansi'] = remove_ansi env.filters['markdown'] = markdown env.filters['highlight'] = highlight +env.filters['ansi2html'] = ansi2html class ConverterTemplate(Configurable): @@ -87,6 +88,11 @@ class ConverterTemplate(Configurable): for worksheet in self.nb.worksheets: for cell in worksheet.cells: cell.type = cell.cell_type + cell.haspyout = False + for out in cell.get('outputs',[]): + if out.output_type == 'pyout': + cell.haspyout = True + break converted_cells.append(worksheet) return converted_cells diff --git a/templates/basichtml.tpl b/templates/basichtml.tpl index 8906f57..af9572e 100644 --- a/templates/basichtml.tpl +++ b/templates/basichtml.tpl @@ -30,8 +30,7 @@ {% block output_prompt -%}
-{%- if cell.prompt_number is not none -%} -{#- check the case of Out[#]-#} +{%- if cell.haspyout -%} Out[{{cell.prompt_number}}]: {%- endif -%}
@@ -59,7 +58,7 @@ Out[{{cell.prompt_number}}]: {% endblock headingcell %} {% block rawcell scoped %} -{{ cell.source | pycomment }} +{{ cell.source }} {% endblock rawcell %} {% block unknowncell scoped %} @@ -69,12 +68,29 @@ unknown type {{cell.type}} {% block pyout -%}
-
{{output.text}}
+
{{output.text | ansi2html}}
{%- endblock pyout %} {% block stream -%}
-
{{output.text}}
+
{{output.text |ansi2html}}
{%- endblock stream %} + +{% block display_data -%} +
+{{output.svg}} +
+{%- endblock display_data %} + + +{% block pyerr -%} +
+
{{super()}}
+
+{%- endblock pyerr %} + +{%- block traceback_line %} +{{line| ansi2html}} +{%- endblock traceback_line %} diff --git a/templates/fullhtml.tpl b/templates/fullhtml.tpl index be9add0..eafd67b 100644 --- a/templates/fullhtml.tpl +++ b/templates/fullhtml.tpl @@ -771,9 +771,9 @@ init_mathjax(); {% block body %} -{{ super() }} - -{% endblock body %} +{{ super() }} + +{%- endblock body %} @@ -783,5 +783,4 @@ init_mathjax(); {% block footer %} - -{% endblock footer %} +{% endblock footer %}