Skip to content

Commit 25bcbbe

Browse files
committed
feat: Abort with error when the plugin is configured to require the ANSI extra but it is not installed
1 parent 6b845e8 commit 25bcbbe

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/markdown_exec/mkdocs_plugin.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
8080
if "pymdownx.superfences" not in config["markdown_extensions"]:
8181
message = "The 'markdown-exec' plugin requires the 'pymdownx.superfences' Markdown extension to work."
8282
raise PluginError(message)
83+
if self.config.ansi in ("required", True) and not ansi_ok:
84+
raise PluginError(
85+
"The configuration for the 'markdown-exec' plugin requires "
86+
"that it is installed with the 'ansi' extra. "
87+
"Install it with 'pip install markdown-exec[ansi]'.",
88+
)
8389
self.mkdocs_config_dir = os.getenv("MKDOCS_CONFIG_DIR")
8490
os.environ["MKDOCS_CONFIG_DIR"] = os.path.dirname(config["config_file_path"])
8591
self.languages = self.config.languages

0 commit comments

Comments
 (0)