|
@@ -26,6 +26,7 @@ import re
|
|
import base64
|
|
import base64
|
|
import urllib2
|
|
import urllib2
|
|
from .mdx_liquid_tags import LiquidTags
|
|
from .mdx_liquid_tags import LiquidTags
|
|
|
|
+import six
|
|
|
|
|
|
SYNTAX = '{% b64img [class name(s)] [http[s]:/]/path/to/image [width [height]] [title text | "title text" ["alt text"]] %}'
|
|
SYNTAX = '{% b64img [class name(s)] [http[s]:/]/path/to/image [width [height]] [title text | "title text" ["alt text"]] %}'
|
|
|
|
|
|
@@ -45,7 +46,7 @@ def _get_file(src):
|
|
else:
|
|
else:
|
|
with open(src, 'rb') as fh:
|
|
with open(src, 'rb') as fh:
|
|
return fh.read()
|
|
return fh.read()
|
|
- except Exception, e:
|
|
|
|
|
|
+ except Exception as e:
|
|
raise RuntimeError('Error generating base64image: {}'.format(e))
|
|
raise RuntimeError('Error generating base64image: {}'.format(e))
|
|
|
|
|
|
|
|
|
|
@@ -62,7 +63,7 @@ def b64img(preprocessor, tag, markup):
|
|
match = ReImg.search(markup)
|
|
match = ReImg.search(markup)
|
|
if match:
|
|
if match:
|
|
attrs = dict([(key, val.strip())
|
|
attrs = dict([(key, val.strip())
|
|
- for (key, val) in match.groupdict().iteritems() if val])
|
|
|
|
|
|
+ for (key, val) in six.iteritems(match.groupdict()) if val])
|
|
else:
|
|
else:
|
|
raise ValueError('Error processing input. '
|
|
raise ValueError('Error processing input. '
|
|
'Expected syntax: {0}'.format(SYNTAX))
|
|
'Expected syntax: {0}'.format(SYNTAX))
|
|
@@ -79,9 +80,9 @@ def b64img(preprocessor, tag, markup):
|
|
|
|
|
|
# Return the formatted text
|
|
# Return the formatted text
|
|
return "<img {0}>".format(' '.join('{0}="{1}"'.format(key, val)
|
|
return "<img {0}>".format(' '.join('{0}="{1}"'.format(key, val)
|
|
- for (key, val) in attrs.iteritems()))
|
|
|
|
|
|
+ for (key, val) in six.iteritems(attrs)))
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
#----------------------------------------------------------------------
|
|
# This import allows image tag to be a Pelican plugin
|
|
# This import allows image tag to be a Pelican plugin
|
|
-from liquid_tags import register
|
|
|
|
|
|
+from .liquid_tags import register
|