From 0038533666ec51a9681c2eed34031eacf65829f9 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sat, 24 Oct 2026 03:05:12 +0200 Subject: [PATCH] fix: mark short code inside mdx pages too --- website/src/plugins/rehype-short-code.mjs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/website/src/plugins/rehype-short-code.mjs b/website/src/plugins/rehype-short-code.mjs index ab724a8b..56666063 100644 --- a/website/src/plugins/rehype-short-code.mjs +++ b/website/src/plugins/rehype-short-code.mjs @@ -150,5 +150,15 @@ export default function shortCode() { }, }, ], + // In an MDX page (one with tabs) inline HTML is JSX: a `` + // hash in a table cell reaches neither raw() nor element. Long JSX code + // gets its breaks from site.ts. + mdxJsxTextElement: { + filter: ['code'], + visit(code, ctx) { + const named = (code.attributes ?? []).some((attribute) => ['class', 'className'].includes(attribute.name)); + if (!named && isShort(ctx.textContent(code), false)) ctx.setProperty(code, 'class', 'rb-short'); + }, + }, }; }