Background
The translation pipeline currently protects JSX/MDX attribute syntax only via prompt instructions. The integration test (scripts/eval/jsx-preservation.integration.test.ts) explicitly documents that this is non-deterministic:
"Before that implementation [scripts/shared/jsxPlaceholders.ts] exists, these tests will fail non-deterministically because the LLM can corrupt JSX attribute syntax"
The file scripts/shared/jsxPlaceholders.ts is referenced as the intended fix but does not yet exist.
What to implement
A jsxPlaceholders.ts module (analogous to localeImagePlaceholders.ts) that:
- Before translation: scans the markdown for JSX blocks and attributes (e.g.
<Tabs>, <TabItem value="android">, MDX import/export statements) and replaces them with stable opaque tokens that the LLM will not alter.
- After translation: restores the original JSX from the tokens.
The mask/restore approach makes JSX preservation deterministic regardless of LLM behaviour.
Acceptance criterion
The existing integration tests in scripts/eval/jsx-preservation.integration.test.ts should pass reliably when RUN_LIVE_TRANSLATION_TESTS=1 without the prompt-only protection being the sole guard.
Background
The translation pipeline currently protects JSX/MDX attribute syntax only via prompt instructions. The integration test (
scripts/eval/jsx-preservation.integration.test.ts) explicitly documents that this is non-deterministic:The file
scripts/shared/jsxPlaceholders.tsis referenced as the intended fix but does not yet exist.What to implement
A
jsxPlaceholders.tsmodule (analogous tolocaleImagePlaceholders.ts) that:<Tabs>,<TabItem value="android">, MDX import/export statements) and replaces them with stable opaque tokens that the LLM will not alter.The mask/restore approach makes JSX preservation deterministic regardless of LLM behaviour.
Acceptance criterion
The existing integration tests in
scripts/eval/jsx-preservation.integration.test.tsshould pass reliably whenRUN_LIVE_TRANSLATION_TESTS=1without the prompt-only protection being the sole guard.