diff --git a/markdown/__init__.py b/markdown/__init__.py index 890d0377..e97c7e90 100644 --- a/markdown/__init__.py +++ b/markdown/__init__.py @@ -38,7 +38,12 @@ import sys import sublime import logging -import importlib +try: + # ST3 + import importlib +except ImportError: + # ST2 + pass from . import util from .preprocessors import build_preprocessors from .blockprocessors import build_block_parser @@ -202,7 +207,10 @@ def build_extension(self, ext_name, configs = []): # Try loading the extension first from one place, then another try: # New style (markdown.extensons.) - module = importlib.import_module(module_name) + if 'importlib' in globals(): + module = importlib.import_module(module_name) + else: + module = __import__(module_name, {}, {}, [module_name.rpartition('.')[0]]) except ImportError: module_name_old_style = '_'.join(['mdx', ext_name]) try: # Old style (mdx_)