summaryrefslogtreecommitdiff
path: root/src/mistune/plugins/__init__.py
diff options
context:
space:
mode:
authorArturs Artamonovs <dos21h@gmail.com>2023-01-29 10:30:54 +0000
committerArturs Artamonovs <dos21h@gmail.com>2023-01-29 10:30:54 +0000
commit66fa71a8f11b6ce5e8471b533f67cc3a1fdb85a8 (patch)
tree7aed7f385826a3bd88c76a373e28c6cfae4f396e /src/mistune/plugins/__init__.py
parent129c1201ea5c4418f0f89ad932633c7cea2439b7 (diff)
downloadmd-site-66fa71a8f11b6ce5e8471b533f67cc3a1fdb85a8.tar.gz
md-site-66fa71a8f11b6ce5e8471b533f67cc3a1fdb85a8.zip
Update to new mistune, removed old mistune, rewrite to python3
Diffstat (limited to 'src/mistune/plugins/__init__.py')
-rw-r--r--src/mistune/plugins/__init__.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/mistune/plugins/__init__.py b/src/mistune/plugins/__init__.py
new file mode 100644
index 0000000..a79d727
--- /dev/null
+++ b/src/mistune/plugins/__init__.py
@@ -0,0 +1,38 @@
+from importlib import import_module
+
+_plugins = {
+ 'speedup': 'mistune.plugins.speedup.speedup',
+ 'strikethrough': 'mistune.plugins.formatting.strikethrough',
+ 'mark': 'mistune.plugins.formatting.mark',
+ 'insert': 'mistune.plugins.formatting.insert',
+ 'superscript': 'mistune.plugins.formatting.superscript',
+ 'subscript': 'mistune.plugins.formatting.subscript',
+ 'footnotes': 'mistune.plugins.footnotes.footnotes',
+ 'table': 'mistune.plugins.table.table',
+ 'url': 'mistune.plugins.url.url',
+ 'abbr': 'mistune.plugins.abbr.abbr',
+ 'def_list': 'mistune.plugins.def_list.def_list',
+ 'math': 'mistune.plugins.math.math',
+ 'ruby': 'mistune.plugins.ruby.ruby',
+ 'task_lists': 'mistune.plugins.task_lists.task_lists',
+ 'spoiler': 'mistune.plugins.spoiler.spoiler',
+}
+_cached_modules = {}
+
+
+def import_plugin(name):
+ if name in _cached_modules:
+ return _cached_modules[name]
+
+ if callable(name):
+ return name
+
+ if name in _plugins:
+ module_path, func_name = _plugins[name].rsplit(".", 1)
+ else:
+ module_path, func_name = name.rsplit(".", 1)
+
+ module = import_module(module_path)
+ plugin = getattr(module, func_name)
+ _cached_modules[name] = plugin
+ return plugin