fix: support enabled option in autorefs, glightbox and macros extensions

Signed-off-by: Timothée Mazzucotelli <dev@pawamoy.fr>
This commit is contained in:
Timothée Mazzucotelli
2026-07-07 15:41:55 +02:00
parent 71c976cd96
commit c33d65b0f8
4 changed files with 20 additions and 4 deletions
+6 -4
View File
@@ -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
# ----------------------------------------------------------------------------
+6
View File
@@ -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)
+3
View File
@@ -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)
+5
View File
@@ -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)