Skip to content
Permalink
Browse files

Add ShortcodePlugin class

  • Loading branch information
ralsina committed Aug 2, 2016
1 parent 141ea96 commit 82e03af71a8381a779649d8e5732ba9eb5244c17
Showing with 12 additions and 1 deletion.
  1. +1 −1 docs/extending.txt
  2. +5 −0 nikola/nikola.py
  3. +6 −0 nikola/plugin_categories.py
@@ -577,7 +577,7 @@ So, if you are creating a plugin that generates markup, it may be a good idea
to register it as a shortcode in addition of to restructured text directive or
markdown extension, thus making it available to all markup formats.

To implement your own shortcodes from a plugin, you can call
To implement your own shortcodes from a plugin, you can create a plugin inheriting ``ShortcodePlugin`` and call
``Nikola.register_shortcode(name, func)`` with the following arguments:

``name``:
@@ -66,6 +66,7 @@
CompilerExtension,
MarkdownExtension,
RestExtension,
ShortcodePlugin,
Task,
TaskMultiplier,
TemplateSystem,
@@ -892,6 +893,7 @@ def init_plugins(self, commands_only=False, load_all=False):
"CompilerExtension": CompilerExtension,
"MarkdownExtension": MarkdownExtension,
"RestExtension": RestExtension,
"ShortcodePlugin": ShortcodePlugin,
"SignalHandler": SignalHandler,
"ConfigPlugin": ConfigPlugin,
"PostScanner": PostScanner,
@@ -990,6 +992,9 @@ def plugin_position_in_places(plugin):
self.plugin_manager.activatePluginByName(plugin_info.name)
plugin_info.plugin_object.set_site(self)

# Activate shortcode plugins
self._activate_plugins_of_category("ShortcodePlugin")

# Load compiler plugins
self.compilers = {}
self.inverse_compilers = {}
@@ -344,6 +344,12 @@ class ConfigPlugin(BasePlugin):
name = "dummy_config_plugin"


class ShortcodePlugin(BasePlugin):
"""A plugin that adds a shortcode."""

name = "dummy_shortcode_plugin"


class Importer(Command):
"""Basic structure for importing data into Nikola.

0 comments on commit 82e03af

Please sign in to comment.