def load_extension(ext_name, configs=[]):
 configs = dict(configs)
 pos = ext_name.find('(')
 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])
 ext_module = 'markdown.extensions'
 module_name_new_style = '.'.join([ext_module, ext_name])
 module_name_old_style = '_'.join(['mdx', ext_name])
 try:
  module = __import__(module_name_new_style, {}, {}, [ext_module])
 except ImportError:
  try:
   module = __import__(module_name_old_style)
  except ImportError:
   message(WARN, ("Failed loading extension '%s' from '%s' or '%s'" % (ext_name, module_name_new_style, module_name_old_style)))
   return None
 try:
  return module.makeExtension(configs.items())
 except AttributeError:
  message(CRITICAL, ("Failed to initiate extension '%s'" % ext_name))

def load_extension ( ext_name , configs = [ ] ) : configs = dict ( configs ) pos = ext_name . find ( '(' ) 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 ] ) ext_module = 'markdown.extensions' module_name_new_style = '.' . join ( [ ext_module , ext_name ] ) module_name_old_style = '_' . join ( [ 'mdx' , ext_name ] ) try : module = __import__ ( module_name_new_style , { } , { } , [ ext_module ] ) except ImportError : try : module = __import__ ( module_name_old_style ) except ImportError : message ( WARN , ( "Failed loading extension '%s' from '%s' or '%s'" % ( ext_name , module_name_new_style , module_name_old_style ) ) ) return None try : return module . makeExtension ( configs . items ( ) ) except AttributeError : message ( CRITICAL , ( "Failed to initiate extension '%s'" % ext_name ) )
load extension by name .