Skip to content

Commit

Permalink
feat: Detect when SuperFences is not enabled and error out early
Browse files Browse the repository at this point in the history
Issue-39: #39
  • Loading branch information
pawamoy committed Jun 13, 2024
1 parent 53174cc commit 5d771d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ markdown_extensions:
plugins:
- search
- markdown-exec

# SuperFences must still be enabled!
markdown_extensions:
- pymdownx.superfences
```
We do recommend enabling Markdown Exec with the MkDocs plugin
Expand Down
4 changes: 4 additions & 0 deletions src/markdown_exec/mkdocs_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from mkdocs.config import config_options
from mkdocs.config.base import Config
from mkdocs.exceptions import PluginError
from mkdocs.plugins import BasePlugin
from mkdocs.utils import write_file

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

0 comments on commit 5d771d2

Please sign in to comment.