M src/wiki/core/markdown/__init__.py => src/wiki/core/markdown/__init__.py +3 -6
@@ 1,9 1,6 @@
import bleach
import markdown
from wiki.conf import settings
-from wiki.core.markdown.mdx.codehilite import WikiCodeHiliteExtension
-from wiki.core.markdown.mdx.previewlinks import PreviewLinksExtension
-from wiki.core.markdown.mdx.responsivetable import ResponsiveTableExtension
from wiki.core.plugins import registry as plugin_registry
@@ 20,9 17,9 @@ class ArticleMarkdown(markdown.Markdown):
def core_extensions(self):
"""List of core extensions found in the mdx folder"""
return [
- PreviewLinksExtension(),
- ResponsiveTableExtension(),
- WikiCodeHiliteExtension(),
+ 'wiki.core.markdown.mdx.codehilite',
+ 'wiki.core.markdown.mdx.previewlinks',
+ 'wiki.core.markdown.mdx.responsivetable',
]
def get_markdown_extensions(self):
M src/wiki/core/markdown/mdx/codehilite.py => src/wiki/core/markdown/mdx/codehilite.py +5 -0
@@ 117,3 117,8 @@ class WikiCodeHiliteExtension(CodeHiliteExtension):
">normalize_whitespace")
md.registerExtension(self)
+
+
+def makeExtension(*args, **kwargs):
+ """Return an instance of the extension."""
+ return WikiCodeHiliteExtension(*args, **kwargs)
M src/wiki/core/markdown/mdx/previewlinks.py => src/wiki/core/markdown/mdx/previewlinks.py +5 -0
@@ 19,3 19,8 @@ class PreviewLinksTree(Treeprocessor):
if not a.get('href').startswith('#'):
a.set('target', '_blank')
return root
+
+
+def makeExtension(*args, **kwargs):
+ """Return an instance of the extension."""
+ return PreviewLinksExtension(*args, **kwargs)
M src/wiki/core/markdown/mdx/responsivetable.py => src/wiki/core/markdown/mdx/responsivetable.py +5 -0
@@ 37,3 37,8 @@ class ResponsiveTableTree(Treeprocessor):
def convert_to_wrapper(self, element):
element.tag = 'div'
element.set('class', 'table-responsive')
+
+
+def makeExtension(*args, **kwargs):
+ """Return an instance of the extension."""
+ return ResponsiveTableExtension(*args, **kwargs)
M src/wiki/plugins/macros/mdx/macro.py => src/wiki/plugins/macros/mdx/macro.py +5 -0
@@ 99,3 99,8 @@ class MacroPreprocessor(markdown.preprocessors.Preprocessor):
'Insert a link to another wiki page with a short notation.'),
example_code='[[WikiLink]]',
args={})
+
+
+def makeExtension(*args, **kwargs):
+ """Return an instance of the extension."""
+ return MacroExtension(*args, **kwargs)
M src/wiki/plugins/macros/mdx/toc.py => src/wiki/plugins/macros/mdx/toc.py +5 -0
@@ 309,3 309,8 @@ class WikiTocExtension(TocExtension):
def extendMarkdown(self, md, md_globals):
if 'toc' in settings.METHODS:
TocExtension.extendMarkdown(self, md, md_globals)
+
+
+def makeExtension(*args, **kwargs):
+ """Return an instance of the extension."""
+ return WikiTocExtension(*args, **kwargs)
M src/wiki/plugins/macros/mdx/wikilinks.py => src/wiki/plugins/macros/mdx/wikilinks.py +5 -0
@@ 62,3 62,8 @@ class WikiLinks(wikilinks.WikiLinks):
else:
a = ''
return a
+
+
+def makeExtension(*args, **kwargs):
+ """Return an instance of the extension."""
+ return WikiLinkExtension(*args, **kwargs)
M src/wiki/plugins/macros/wiki_plugin.py => src/wiki/plugins/macros/wiki_plugin.py +4 -6
@@ 2,9 2,6 @@ from django.utils.translation import gettext as _
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
from wiki.plugins.macros import settings
-from wiki.plugins.macros.mdx.macro import MacroExtension
-from wiki.plugins.macros.mdx.toc import WikiTocExtension
-from wiki.plugins.macros.mdx.wikilinks import WikiLinkExtension
class MacroPlugin(BasePlugin):
@@ 18,9 15,10 @@ class MacroPlugin(BasePlugin):
'get_form_kwargs': (lambda a: {})}
markdown_extensions = [
- WikiLinkExtension(),
- MacroExtension(),
- WikiTocExtension()]
+ 'wiki.plugins.macros.mdx.macro',
+ 'wiki.plugins.macros.mdx.toc',
+ 'wiki.plugins.macros.mdx.wikilinks',
+ ]
registry.register(MacroPlugin)