From e4fa679599d3563df0b232a8ca30d322ebd5b188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 15 Dec 2025 13:01:49 +0100 Subject: [PATCH] zensical:fix - Support keywords for custom fence formatter/validator (#196) #193 Signed-off-by: pawamoy --- python/zensical/config.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/python/zensical/config.py b/python/zensical/config.py index 2905f0e..162912d 100644 --- a/python/zensical/config.py +++ b/python/zensical/config.py @@ -381,8 +381,15 @@ def _apply_defaults(config: dict, path: str) -> dict: for fence in superfences.get("custom_fences", []): if isinstance(fence.get("format"), str): fence["format"] = _resolve(fence.get("format")) + elif isinstance(fence.get("format"), dict): + object = fence["format"].get("object", "pymdownx.superfences.fence_code_format") + fence["format"] = _resolve(object)(**fence["format"].get("kwds", {})) if isinstance(fence.get("validator"), str): fence["validator"] = _resolve(fence.get("validator")) + elif isinstance(fence.get("validator"), dict): + object = fence["validator"].get("object") + callable_object = _resolve(object) if object else lambda *args, **kwargs: True + fence["validator"] = callable_object(**fence["validator"].get("kwds", {})) # Ensure the table of contents title is initialized, as it's used inside # the template, and the table of contents extension is always defined