diff --git a/isso/utils/html.py b/isso/utils/html.py
index df60ad8..34a4dc7 100644
--- a/isso/utils/html.py
+++ b/isso/utils/html.py
@@ -1,6 +1,9 @@
# -*- encoding: utf-8 -*-
+import pkg_resources
+
import html5lib
+setattr(html5lib, "version", pkg_resources.get_distribution("html5lib").version)
from html5lib.sanitizer import HTMLSanitizer
from html5lib.serializer import HTMLSerializer
@@ -34,7 +37,8 @@ def sanitize(document):
parser = html5lib.HTMLParser(tokenizer=MarkdownSanitizer)
domtree = parser.parseFragment(document)
- stream = html5lib.treewalkers.getTreeWalker('etree')(domtree)
+ builder = "simpletree" if html5lib.version == "0.95" else "etree"
+ stream = html5lib.treewalkers.getTreeWalker(builder)(domtree)
serializer = HTMLSerializer(quote_attr_values=True, omit_optional_tags=False)
return serializer.render(stream)
diff --git a/tox.ini b/tox.ini
index 5ba997b..aa9df38 100755
--- a/tox.ini
+++ b/tox.ini
@@ -13,6 +13,7 @@ deps =
deps =
configparser
werkzeug==0.8.3
+ html5lib==0.95
{[testenv]deps}
[testenv]
deps =