diff --git a/mdx_oembed/__init__.py b/mdx_oembed/__init__.py index 4395f4b..f1cd610 100644 --- a/mdx_oembed/__init__.py +++ b/mdx_oembed/__init__.py @@ -3,4 +3,6 @@ from mdx_oembed.extension import OEmbedExtension def makeExtension(configs=None): + if isinstance(configs, list): + configs = dict(configs) return OEmbedExtension(configs=configs) diff --git a/mdx_oembed/extension.py b/mdx_oembed/extension.py index 8c7a86d..84e84a6 100644 --- a/mdx_oembed/extension.py +++ b/mdx_oembed/extension.py @@ -5,16 +5,28 @@ from mdx_oembed.endpoints import ENDPOINTS from mdx_oembed.inlinepatterns import OEmbedLinkPattern, OEMBED_LINK_RE +AVAILABLE_ENDPOINTS = ENDPOINTS.keys() + + class OEmbedExtension(Extension): + config = { + 'allowed_endpoints': [ + AVAILABLE_ENDPOINTS, + "A list of oEmbed endpoints to allow. Possible values are " + "{}.".format(', '.join(AVAILABLE_ENDPOINTS)), + ], + } + def extendMarkdown(self, md, md_globals): self.oembed_consumer = self.prepare_oembed_consumer() - pattern = OEmbedLinkPattern(OEMBED_LINK_RE, md, self.oembed_consumer) - md.inlinePatterns.add('oembed_link', pattern, '