From 46922c116be7e0821db30210ef62acc9585001cd Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Wed, 14 Jan 2026 07:16:17 -0800 Subject: [PATCH] Strip markdown-code-runner modifier from code fences in docs The docs site renderer (Zensical/pymdownx) doesn't understand the "python markdown-code-runner" syntax for code fence language identifiers. This causes the fenced code blocks to be parsed as inline code instead of proper code blocks, breaking the rendering. Add a regex transformation in _transform_readme_links() to strip the "markdown-code-runner" modifier when pulling content from README into the docs templates. --- docs/docs_gen.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/docs_gen.py b/docs/docs_gen.py index 07288a7..8c96133 100755 --- a/docs/docs_gen.py +++ b/docs/docs_gen.py @@ -98,7 +98,17 @@ def _transform_readme_links(content: str) -> str: content = content.replace(f"]({old_link})", f"]({new_link})") # Remove ToC link pattern [[ToC](#...)] - return re.sub(r"\[\[ToC\]\([^)]+\)\]", "", content) + content = re.sub(r"\[\[ToC\]\([^)]+\)\]", "", content) + + # Strip 'markdown-code-runner' modifier from code fence language identifiers + # e.g., "```python markdown-code-runner" -> "```python" + # This is needed because the docs site renderer doesn't understand this syntax + return re.sub( + r"^(```\w+)\s+markdown-code-runner(?:\s+\S+=\S+)?$", + r"\1", + content, + flags=re.MULTILINE, + ) def _find_markdown_files_with_code_blocks(docs_dir: Path) -> list[Path]: