'Build extension by name, then return the module.
The extension name may contain arguments as part of the string in the
following format: "extname(key1=value1,key2=value2)"'

def build_extension(self, ext_name, configs):

    configs = dict(configs)
    pos = ext_name.find(u'(')
    if (pos > 0):
        ext_args = ext_name[(pos + 1):(-1)]
        ext_name = ext_name[:pos]
        pairs = [x.split(u'=') for x in ext_args.split(u',')]
        configs.update([(x.strip(), y.strip()) for (x, y) in pairs])
        warnings.warn(u'Setting    configs    in    the    Named    Extension    string    is    deprecated.    It    is    recommended    that    you    pass    an    instance    of    the    extension    class    to    Markdown    or    use    the    "extension_configs"    keyword.    The    current    behavior    will    raise    an    error    in    version    2.7.    See    the    Release    Notes    for    Python-Markdown    version    2.6    for    more    info.', DeprecationWarning)
    (ext_name, class_name) = (ext_name.split(u':', 1) if (u':' in ext_name) else (ext_name, u''))
    try:
        module = importlib.import_module(ext_name)
        logger.debug((u'Successfuly    imported    extension    module    "%s".' % ext_name))
        if ((u'.' not in ext_name) and (not (hasattr(module, u'makeExtension') or (class_name and hasattr(module, class_name))))):
            raise ImportError
    except ImportError:
        module_name = u'.'.join([u'markdown.extensions', ext_name])
        try:
            module = importlib.import_module(module_name)
            logger.debug((u'Successfuly    imported    extension    module    "%s".' % module_name))
            warnings.warn((u'Using    short    names    for    Markdown\'s    builtin    extensions    is    deprecated.    Use    the    full    path    to    the    extension    with    Python\'s    dot    notation    (eg:    "%s"    instead    of    "%s").    The    current    behavior    will    raise    an    error    in    version    2.7.    See    the    Release    Notes    for    Python-Markdown    version    2.6    for    more    info.' % (module_name, ext_name)), DeprecationWarning)
        except ImportError:
            module_name_old_style = u'_'.join([u'mdx', ext_name])
            try:
                module = importlib.import_module(module_name_old_style)
                logger.debug((u'Successfuly    imported    extension    module    "%s".' % module_name_old_style))
                warnings.warn((u'Markdown\'s    behavior    of    prepending    "mdx_"    to    an    extension    name    is    deprecated.    Use    the    full    path    to    the    extension    with    Python\'s    dot    notation    (eg:    "%s"    instead    of    "%s").    The    current    behavior    will    raise    an    error    in    version    2.7.    See    the    Release    Notes    for    Python-Markdown    version    2.6    for    more    info.' % (module_name_old_style, ext_name)), DeprecationWarning)
            except ImportError as e:
                message = (u"Failed    loading    extension    '%s'    from    '%s',    '%s'    or    '%s'" % (ext_name, ext_name, module_name, module_name_old_style))
                e.args = ((message,) + e.args[1:])
                raise
    if class_name:
        return getattr(module, class_name)(**configs)
    else:
        try:
            return module.makeExtension(**configs)
        except AttributeError as e:
            message = e.args[0]
            message = (u"Failed    to    initiate    extension    '%s':    %s" % (ext_name, message))
            e.args = ((message,) + e.args[1:])
            raise
