From 88dff3af82b872a546c0c6ae235d246b80b976ea Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Wed, 11 Nov 2026 14:58:10 +0100 Subject: [PATCH] fix: keep the space between two tags in MDX pages MDX reads a line of tags alone as JSX and drops the space between them: the RetroDECK page, written as MDX for its tabs, read "2007/2008Coverage". mdx_safe writes that space as {" "}, which MDX keeps. Checked against satteri's mdxToHast, not on a built site. --- scripts/sitestarlight.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/sitestarlight.py b/scripts/sitestarlight.py index 4bd8305e3..1480517e7 100644 --- a/scripts/sitestarlight.py +++ b/scripts/sitestarlight.py @@ -274,9 +274,13 @@ _HEADING_ATTRS = re.compile(r"(?m)(?<=\S)[ \t]+\{[ \t]*#[^{}\n]*\}[ \t]*$") _COMMENT = re.compile(r"", re.S) +_TAG_GAP = re.compile(r"()[ \t]+(?=<[A-Za-z])") + + def mdx_safe(text: str) -> str: """What MDX would read as code in prose: braces, a stray ``<``, - comments, unclosed void tags and ```` links.""" + comments, unclosed void tags and ```` links. A space + between two tags is written as an expression MDX keeps.""" def fix(chunk: str) -> str: chunk = _COMMENT.sub("", chunk) chunk = re.sub(r"<(https?://[^>\s]+)>", r"[\1](\1)", chunk) @@ -289,7 +293,10 @@ def mdx_safe(text: str) -> str: chunk = chunk.replace("{", "{").replace("}", "}") chunk = re.sub(r"\x00(\d+)\x00", lambda m: held[int(m[1])], chunk) chunk = re.sub(r"<(?![A-Za-z/])", "<", chunk) - return _VOID.sub(lambda m: f"<{m[1]}{m[2].rstrip()} />", chunk) + chunk = _VOID.sub(lambda m: f"<{m[1]}{m[2].rstrip()} />", chunk) + # A line of tags alone is JSX to MDX, which drops the space between + # them: a setup page with tabs read "2007/2008Coverage". + return _TAG_GAP.sub(r'\1{" "}', chunk) return outside_code(text, fix)