Skip to content

Commit 5d771d2

Browse files
committed
feat: Detect when SuperFences is not enabled and error out early
Issue-39: #39
1 parent 53174cc commit 5d771d2

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ markdown_extensions:
7878
plugins:
7979
- search
8080
- markdown-exec
81+
82+
# SuperFences must still be enabled!
83+
markdown_extensions:
84+
- pymdownx.superfences
8185
```
8286
8387
We do recommend enabling Markdown Exec with the MkDocs plugin

src/markdown_exec/mkdocs_plugin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from mkdocs.config import config_options
1111
from mkdocs.config.base import Config
12+
from mkdocs.exceptions import PluginError
1213
from mkdocs.plugins import BasePlugin
1314
from mkdocs.utils import write_file
1415

@@ -76,6 +77,9 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
7677
Returns:
7778
The modified config.
7879
"""
80+
if "pymdownx.superfences" not in config["markdown_extensions"]:
81+
message = "The 'markdown-exec' plugin requires the 'pymdownx.superfences' Markdown extension to work."
82+
raise PluginError(message)
7983
self.mkdocs_config_dir = os.getenv("MKDOCS_CONFIG_DIR")
8084
os.environ["MKDOCS_CONFIG_DIR"] = os.path.dirname(config["config_file_path"])
8185
self.languages = self.config.languages

0 commit comments

Comments
 (0)