Skip to content

Commit 27743c2

Browse files
committed
feat: Add ansi option to mark ANSI extra as required or not
This helps decide whether to include the ANSI CSS file into the final site. Issue #28: #28 Issue #29: #29
1 parent e6ff1dd commit 27743c2

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ markdown_extensions:
120120

121121
plugins:
122122
- search
123-
- markdown-exec
123+
- markdown-exec:
124+
ansi: required
124125
- gen-files:
125126
scripts:
126127
- scripts/gen_ref_nav.py

src/markdown_exec/mkdocs_plugin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def _get_logger(name: str) -> _LoggerAdapter:
4949
class MarkdownExecPluginConfig(Config):
5050
"""Configuration of the plugin (for `mkdocs.yml`)."""
5151

52+
ansi: str | bool = config_options.Choice(("auto", "off", "required", True, False), default="auto")
53+
"""Whether the `ansi` extra is required when installing the package."""
5254
languages: list[str] = config_options.ListOfItems(config_options.Choice(formatters.keys()), default=list(formatters.keys()))
5355
"""Which languages to enabled the extension for."""
5456

@@ -96,7 +98,8 @@ def on_env( # noqa: D102
9698
config: MkDocsConfig,
9799
files: Files, # noqa: ARG002
98100
) -> Environment | None:
99-
self._add_css(config, "ansi.css")
101+
if self.config.ansi in ("required", True) or (self.config.ansi == "auto" and ansi_ok):
102+
self._add_css(config, "ansi.css")
100103
if "pyodide" in self.languages:
101104
self._add_css(config, "pyodide.css")
102105
self._add_js(config, "pyodide.js")

0 commit comments

Comments
 (0)