diff --git a/www/hooks/use-markdown.tsx b/www/hooks/use-markdown.tsx index f035efd13..d9896a972 100644 --- a/www/hooks/use-markdown.tsx +++ b/www/hooks/use-markdown.tsx @@ -49,6 +49,14 @@ export function* useMarkdown( ); let sanitized = yield* sanitize(markdown); + // Escape generic type parameters like , that MDX + // would interpret as JSX tags. Only matches uppercase-starting identifiers + // inside angle brackets to avoid escaping actual HTML tags. + sanitized = sanitized.replace( + /<([A-Z]\w*(?:\s*,\s*[A-Z]\w*)*)>/g, + "<$1>", + ); + let mod = yield* useMDX(sanitized, { remarkPlugins: [remarkGfm, ...(options?.remarkPlugins ?? [])], rehypePlugins: [