Commits

almad  committed 949ca0c

Make html5lib usage (back/for)wards compatible

  • Participants
  • Parent commits 3a6b852
  • Tags python-czechtile-0.3

Comments (0)

Files changed (1)

File czechtile/expanders/xhtml11.py

-from html5lib.constants import tokenTypes
+try:
+    from html5lib.constants import tokenTypes
+    START_TAG_CONST = tokenTypes['StartTag']
+except ImportError:
+    START_TAG_CONST = "StartTag"
 from html5lib.sanitizer import HTMLSanitizerMixin
 
 from .. import nodes
     def expand(self, node, format, node_map):
         # sanitize the picture location
         sanitizer = HTMLSanitizerMixin()
-        tokens = sanitizer.sanitize_token({'type': tokenTypes['StartTag'], \
+        tokens = sanitizer.sanitize_token({'type': START_TAG_CONST, \
             'name': 'img', 'data': [('src', node.source)]})['data']
 
         # look for the src attribute in tokens