(self, ext_name, configs = [])
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)"
Build extension by name, then return the module.
Build extension by name then return the module .
def build_extension(self, ext_name, configs = []):
        """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)"

        """

        # Parse extensions config params (ignore the order)
        configs = dict(configs)
        pos = ext_name.find("(") # find the first "("
        if pos > 0:
            ext_args = ext_name[pos+1:-1]
            ext_name = ext_name[:pos]
            pairs = [x.split("=") for x in ext_args.split(",")]
            configs.update([(x.strip(), y.strip()) for (x, y) in pairs])

        # Setup the module name
        module_name = ext_name
        if '.' not in ext_name:
            module_name = '.'.join(['markdown.extensions', ext_name])

        # Try loading the extension first from one place, then another
        try: # New style (markdown.extensons.<extension>)
            module = __import__(module_name, {}, {}, [module_name.rpartition('.')[0]])
        except ImportError:
            module_name_old_style = '_'.join(['mdx', ext_name])
            try: # Old style (mdx_<extension>)
                module = __import__(module_name_old_style)
            except ImportError:
                logger.warn("Failed loading extension '%s' from '%s' or '%s'"
                    % (ext_name, module_name, module_name_old_style))
                # Return None so we don't try to initiate none-existant extension
                return None

        # If the module is loaded successfully, we expect it to define a
        # function called makeExtension()
        try:
            return module.makeExtension(configs.items())
        except AttributeError, e:
            logger.warn("Failed to initiate extension '%s': %s" % (ext_name, e))
            return None
def build_extension ( self , ext_name , configs = [ ] ) : # Parse extensions config params (ignore the order) configs = dict ( configs ) pos = ext_name . find ( "(" ) # find the first "(" if pos > 0 : ext_args = ext_name [ pos + 1 : - 1 ] ext_name = ext_name [ : pos ] pairs = [ x . split ( "=" ) for x in ext_args . split ( "," ) ] configs . update ( [ ( x . strip ( ) , y . strip ( ) ) for ( x , y ) in pairs ] ) # Setup the module name module_name = ext_name if '.' not in ext_name : module_name = '.' . join ( [ 'markdown.extensions' , ext_name ] ) # Try loading the extension first from one place, then another try : # New style (markdown.extensons.<extension>) module = __import__ ( module_name , { } , { } , [ module_name . rpartition ( '.' ) [ 0 ] ] ) except ImportError : module_name_old_style = '_' . join ( [ 'mdx' , ext_name ] ) try : # Old style (mdx_<extension>) module = __import__ ( module_name_old_style ) except ImportError : logger . warn ( "Failed loading extension '%s' from '%s' or '%s'" % ( ext_name , module_name , module_name_old_style ) ) # Return None so we don't try to initiate none-existant extension return None # If the module is loaded successfully, we expect it to define a # function called makeExtension() try : return module . makeExtension ( configs . items ( ) ) except AttributeError , e : logger . warn ( "Failed to initiate extension '%s': %s" % ( ext_name , e ) ) return None