diff --git a/converters/template.py b/converters/template.py
index 7c360eb..e81f754 100755
--- a/converters/template.py
+++ b/converters/template.py
@@ -29,7 +29,10 @@ import re
 from types import FunctionType
 
 from jinja2 import Environment, PackageLoader, FileSystemLoader
-env = Environment(loader=FileSystemLoader('./templates/'))
+env = Environment(
+        loader=FileSystemLoader('./templates/'), 
+        extensions=['jinja2.ext.loopcontrols']
+        )
 
 # IPython imports
 from IPython.nbformat import current as nbformat
@@ -92,6 +95,14 @@ def header_body():
 inlining= {}
 inlining['css'] = header_body()
 
+
+def filter_data_type(output):
+    for fmt in ['html', 'pdf', 'svg', 'latex','png', 'jpg','jpeg' , 'text']:
+        if fmt in output:
+            return [fmt]
+
+
+env.filters['filter_data_type'] = filter_data_type
 env.filters['pycomment'] = python_comment
 env.filters['indent'] = indent
 env.filters['rm_fake'] = rm_fake
diff --git a/runme.py b/runme.py
index c919f45..f06afda 100755
--- a/runme.py
+++ b/runme.py
@@ -1,10 +1,11 @@
 #!/usr/bin/env python
 # coding: utf-8
+
 from __future__ import print_function
 import sys
 import io
 from converters.template import *
 C = ConverterTemplate(tplfile=sys.argv[1])
-C.read('tests/ipynbref/IntroNumPy.orig.ipynb')
+C.read(sys.argv[2])
 
 print(C.convert().encode('utf-8'))
diff --git a/templates/basichtml.tpl b/templates/basichtml.tpl
index af9572e..bf2a6ca 100644
--- a/templates/basichtml.tpl
+++ b/templates/basichtml.tpl
@@ -1,4 +1,4 @@
-{%- extends 'null.tpl' -%}
+{%- extends 'display_priority.tpl' -%}
 
 
 
@@ -68,7 +68,7 @@ unknown type  {{cell.type}}
 
 {% block pyout -%}
 <div class="output_subarea output_pyout">
-<pre>{{output.text | ansi2html}}</pre>
+{% block data_priority scoped %}{{ super()}}{% endblock %}
 </div>
 {%- endblock pyout %}
 
@@ -78,13 +78,33 @@ unknown type  {{cell.type}}
 </div>
 {%- endblock stream %}
 
-{% block display_data -%}
-<div class="output_subarea output_display_data">
+{% block data_svg -%}
 {{output.svg}}
 </div>
-{%- endblock display_data %}
+{%- endblock data_svg %}
 
 
+{% block data_html %}
+{{output.html}}
+</div>
+{%- endblock data_html %}
+
+{% block data_png %}
+<img src="data:image/png;base64,{{output.png}}"></img>
+</div>
+{%- endblock data_png %}
+
+
+{% block data_jpg %}
+<img src="data:image/jpeg;base64,{{output.jpeg}}"></img>
+</div>
+{%- endblock data_jpg %}
+
+
+{% block data_latex %}
+{{output.latex}}
+{%- endblock data_latex %}
+
 {% block pyerr -%}
 <div class="output_subarea output_pyerr">
 <pre>{{super()}}</pre>
@@ -94,3 +114,8 @@ unknown type  {{cell.type}}
 {%- block traceback_line %}
 {{line| ansi2html}}
 {%- endblock traceback_line %}
+
+
+{%- block data_text %}
+<pre>{{output.text | ansi2html}}</pre>
+{%- endblock -%}
diff --git a/templates/display_priority.tpl b/templates/display_priority.tpl
new file mode 100644
index 0000000..56832dd
--- /dev/null
+++ b/templates/display_priority.tpl
@@ -0,0 +1,45 @@
+{%- extends 'null.tpl' -%}
+
+{#display data priority#}
+
+
+{%- block data_priority scoped -%}
+    {%- for type in output | filter_data_type -%}
+        {%- if type in ['pdf']%}
+            {%- block data_pdf -%}
+                ->> pdf
+            {%- endblock -%}
+        {%- endif -%}
+        {%- if type in ['svg']%}
+            {%- block data_svg -%}
+                ->> svg
+            {%- endblock -%}
+        {%- endif -%}
+        {%- if type in ['png']%}
+            {%- block data_png -%}
+                ->> png
+            {%- endblock -%}
+        {%- endif -%}
+        {%- if type in ['html']%}
+            {%- block data_html -%}
+                ->> html
+            {%- endblock -%}
+        {%- endif -%}
+        {%- if type in ['jpeg']%}
+            {%- block data_jpg -%}
+                ->> jpg
+            {%- endblock -%}
+        {%- endif -%}
+        {%- if type in ['text']%}
+            {%- block data_text -%}
+                ->> text
+            {%- endblock -%}
+        {%- endif -%}
+
+        {%- if type in ['latex']%}
+            {%- block data_latex -%}
+                ->> latext
+            {%- endblock -%}
+        {%- endif -%}
+    {%- endfor -%}
+{%- endblock data_priority -%}
diff --git a/templates/null.tpl b/templates/null.tpl
index 08ead27..1a63fba 100644
--- a/templates/null.tpl
+++ b/templates/null.tpl
@@ -43,7 +43,10 @@ consider calling super even if block is leave block, we might insert more block 
                                     {%- elif output.output_type in ['stream'] -%}
                                     {%- block stream scoped -%}{%- endblock stream -%}
                                     {%- elif output.output_type in ['display_data'] -%}
-                                        {%- block display_data scoped -%}{%- endblock display_data -%}
+                                        {%- block display_data scoped -%}
+                                            {%- block data_priority scoped -%}
+                                            {%- endblock data_priority -%}
+                                        {%- endblock display_data -%}
                                     {%- elif output.output_type in ['pyerr'] -%}
                                         {%- block pyerr scoped -%}
                                         {%- for line in output.traceback -%}