mirror of
https://github.com/zensical/zensical.git
synced 2026-08-25 08:36:45 +00:00
fix: support enabled option in autorefs, glightbox and macros extensions
Signed-off-by: Timothée Mazzucotelli <dev@pawamoy.fr>
This commit is contained in:
@@ -877,16 +877,18 @@ def _shim_glightbox(config: dict[str, Any]) -> None:
|
||||
# Map glightbox plugin configuration to the extension configuration
|
||||
if "glightbox" in config["plugins"]:
|
||||
plugin = config["plugins"]["glightbox"]["config"]
|
||||
config["markdown_extensions"].append(GlightboxExtension.name)
|
||||
config["mdx_configs"][GlightboxExtension.name] = plugin
|
||||
if plugin.get("enabled", True):
|
||||
config["markdown_extensions"].append(GlightboxExtension.name)
|
||||
config["mdx_configs"][GlightboxExtension.name] = plugin
|
||||
|
||||
|
||||
def _shim_macros(config: dict[str, Any]) -> None:
|
||||
# Map macros plugin configuration to the extension configuration
|
||||
if "macros" in config["plugins"]:
|
||||
plugin = config["plugins"]["macros"]["config"]
|
||||
config["markdown_extensions"].append(MacrosExtension.name)
|
||||
config["mdx_configs"][MacrosExtension.name] = plugin
|
||||
if plugin.get("enabled", True):
|
||||
config["markdown_extensions"].append(MacrosExtension.name)
|
||||
config["mdx_configs"][MacrosExtension.name] = plugin
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
@@ -366,8 +366,14 @@ class AutorefsExtension(Extension):
|
||||
|
||||
name = "zensical.extensions.autorefs"
|
||||
|
||||
def __init__(self, **kwargs: Any) -> None:
|
||||
"""Initialize the extension."""
|
||||
self._enabled: bool = kwargs.pop("enabled", True)
|
||||
|
||||
def extendMarkdown(self, md: Markdown) -> None:
|
||||
"""Register the Markdown extension."""
|
||||
if not self._enabled:
|
||||
return
|
||||
md.registerExtension(self)
|
||||
|
||||
inline_processor = AutorefsInlineProcessor(md)
|
||||
|
||||
@@ -283,10 +283,13 @@ class GlightboxExtension(Extension):
|
||||
|
||||
def __init__(self, **kwargs: Any) -> None:
|
||||
"""Initialize the extension."""
|
||||
self._enabled: bool = kwargs.pop("enabled", True)
|
||||
self._kwargs = kwargs
|
||||
|
||||
def extendMarkdown(self, md: Markdown) -> None:
|
||||
"""Register Markdown extension."""
|
||||
if not self._enabled:
|
||||
return
|
||||
md.registerExtension(self)
|
||||
config = GlightboxConfig(**self._kwargs)
|
||||
|
||||
|
||||
@@ -378,9 +378,14 @@ class MacrosExtension(Extension):
|
||||
name = "zensical.extensions.macros"
|
||||
|
||||
def __init__(self, **kwargs: Any) -> None:
|
||||
"""Initialize the extension."""
|
||||
self._enabled: bool = kwargs.pop("enabled", True)
|
||||
self._kwargs: dict[str, Any] = kwargs
|
||||
|
||||
def extendMarkdown(self, md: Markdown) -> None:
|
||||
"""Register Markdown extension."""
|
||||
if not self._enabled:
|
||||
return
|
||||
md.registerExtension(self)
|
||||
config = MacrosConfig(**self._kwargs)
|
||||
preprocessor = MacrosPreprocessor(md, config)
|
||||
|
||||
Reference in New Issue
Block a user