From 140a5c5d034463b68801e6eae6ef0926ae6a4d08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Mon, 27 Apr 2026 16:55:56 +0200 Subject: [PATCH] Docs: escape MDX braces in changelog body, not just frontmatter The previous fix relied on a `format: md` frontmatter hint, but Docusaurus 3.9 still ran the changelog through the MDX pipeline and crashed on `@php-wasm/{web,node}-5-2`, taking out test-docs-api-reference and the docs deploy on trunk. Escape `{` and `}` in the body when the refresh script copies the changelog over, and unbreak the v3.1.21 entry now so trunk goes green. --- packages/docs/site/bin/refresh-changelog.ts | 14 +++++++++----- packages/docs/site/docs/main/changelog.md | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/docs/site/bin/refresh-changelog.ts b/packages/docs/site/bin/refresh-changelog.ts index 1d6d0e84ee..feeefff23f 100644 --- a/packages/docs/site/bin/refresh-changelog.ts +++ b/packages/docs/site/bin/refresh-changelog.ts @@ -11,11 +11,15 @@ const existingContent = fs.readFileSync(destinationPath, 'utf-8'); const frontmatterRegex = /^---\n([\s\S]*?)\n---/; const existingFrontmatter = existingContent.match(frontmatterRegex)?.[0] || ''; -// The destination file's frontmatter sets `format: md` so Docusaurus parses -// it as plain CommonMark instead of MDX. Without that, unescaped `{...}` or -// `<...>` in PR titles (e.g. `@php-wasm/{web,node}-5-2`) would be treated as -// JSX and crash the build. -const changelogWithFrontmatter = existingFrontmatter + '\n\n' + changelog; +// Docusaurus 3 parses `.md` files through the MDX pipeline, so unescaped +// `{` / `}` in PR titles (e.g. `@php-wasm/{web,node}-5-2`) get read as JSX +// expressions and crash the SSG with `ReferenceError: web is not defined`. +// The destination file's frontmatter sets `format: md` as a hint, but that +// alone has not been enough in practice — escape the braces directly so the +// content is inert regardless of how Docusaurus parses it. +const escapedChangelog = changelog.replace(/[{}]/g, (c) => '\\' + c); +const changelogWithFrontmatter = + existingFrontmatter + '\n\n' + escapedChangelog; // Write the modified changelog to the destination file fs.writeFileSync(destinationPath, changelogWithFrontmatter, 'utf-8'); diff --git a/packages/docs/site/docs/main/changelog.md b/packages/docs/site/docs/main/changelog.md index b7e588c74a..0c96f1a0c4 100644 --- a/packages/docs/site/docs/main/changelog.md +++ b/packages/docs/site/docs/main/changelog.md @@ -19,7 +19,7 @@ format. ### Various - [Docs] Update trusted publisher setup instructions. ([#3505](https://github.com/WordPress/wordpress-playground/pull/3505)) -- [PHP] Align @php-wasm/{web,node}-5-2 with workspace and add READMEs. ([#3506](https://github.com/WordPress/wordpress-playground/pull/3506)) +- [PHP] Align @php-wasm/\{web,node\}-5-2 with workspace and add READMEs. ([#3506](https://github.com/WordPress/wordpress-playground/pull/3506)) ### Contributors