From 8bc1e2a79dc56f160458f6a8ab65393277a01456 Mon Sep 17 00:00:00 2001 From: Jackson Chen <53205189+PeaWarrior@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:06:14 -0400 Subject: [PATCH] Fix pymdownx.extra config (#214) --- README.md | 3 +++ setup.py | 4 ++-- src/core.py | 13 ++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fded588..a64588f 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,9 @@ We only use `material-mkdocs` as base styles because Backstage also uses the `Ma ## Changelog +### 1.4.2 + - Fixes an issue where individual extension configurations were being ignored if the extension was included within `pymdownx.extra`. See [#147](https://github.com/backstage/mkdocs-techdocs-core/issues/147) + ### 1.4.1 - Introduced mkdocs-redirects plugin (v`1.2.1`). diff --git a/setup.py b/setup.py index 19f7b13..1c5821e 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ setup( name="mkdocs-techdocs-core", - version="1.4.1", + version="1.4.2", description="The core MkDocs plugin used by Backstage's TechDocs as a wrapper around " "multiple MkDocs plugins and Python Markdown extensions", long_description=long_description, @@ -36,7 +36,7 @@ keywords="mkdocs", url="https://github.com/backstage/mkdocs-techdocs-core", author="TechDocs Core", - author_email="pulp-fiction@spotify.com", + author_email="protean@spotify.com", license="Apache-2.0", python_requires=">=3.7", install_requires=required, diff --git a/src/core.py b/src/core.py index b151a83..9d69b3b 100644 --- a/src/core.py +++ b/src/core.py @@ -23,6 +23,7 @@ from material.plugins.search.plugin import SearchPlugin as MaterialSearchPlugin from mkdocs_monorepo_plugin.plugin import MonorepoPlugin from pymdownx.emoji import to_svg +from pymdownx.extra import extra_extensions log = logging.getLogger(__name__) @@ -114,7 +115,6 @@ def on_config(self, config): config["markdown_extensions"].append("pymdownx.mark") config["markdown_extensions"].append("pymdownx.smartsymbols") config["markdown_extensions"].append("pymdownx.snippets") - config["markdown_extensions"].append("pymdownx.superfences") config["markdown_extensions"].append("pymdownx.highlight") config["mdx_configs"]["pymdownx.highlight"] = { "linenums": True, @@ -134,6 +134,17 @@ def on_config(self, config): } config["markdown_extensions"].append("pymdownx.tilde") + # merge individual extension configs under the pymdownx.extra extension namespace if individual extension is supplied by pymdownx.extra + # https://facelessuser.github.io/pymdown-extensions/extensions/extra/ + if "pymdownx.extra" not in config["mdx_configs"]: + config["mdx_configs"]["pymdownx.extra"] = {} + for extension in extra_extensions: + if extension in config["mdx_configs"]: + config["mdx_configs"]["pymdownx.extra"][extension] = config[ + "mdx_configs" + ][extension] + del config["mdx_configs"][extension] + config["markdown_extensions"].append("markdown_inline_graphviz") config["markdown_extensions"].append("plantuml_markdown") config["markdown_extensions"].append("mdx_truly_sane_lists")