* Restore the spaces Next drops before multi-line text with an entity
Next 16.2.6's compiler drops the leading space of a JSX text that spans
more than one line and contains an HTML entity, so policybench.org renders
"52 frontier modelson 100 households" on /expand and four run-together
phrases on the home page. An explicit {" "} puts each space back. A new
test applies the compiler's trigger to every page component, and the
expansion-page test no longer reads React's text separators as spaces.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Drop the no-op separator strip from the expand page test
The test renders with renderToStaticMarkup, which emits no <!-- -->
separators, so the added .replace(/<!-- -->/g, "") changed nothing and
its comment named the wrong cause. The test never saw the /expand defect
because Bun's transpiler keeps the leading space that Next's compiler
drops. The line returns to what main has; a compiler-backed check for the
five fixed spaces follows in the spacing guard test.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Check the spacing guard's cases and the five fixed spaces with Next's SWC
The guard's rule cases were checked against Next's compiler only by hand.
The test now loads Next's own SWC binding, compiles each case with it and
with TypeScript, and requires the case to record what Next renders and
whether that drops a space TypeScript keeps. A second check compiles
ExpandCoverageCopy, ModelLeaderboard and Methodology with Next's SWC and
requires whitespace before each of the five phrases policybench.org ran
together. Run against main's three files, it fails on all five and the
guard names the five lines.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Count only the entities Next's compiler decodes in the spacing guard
The guard's /&(#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/i matched any &name;,
so `{x} after\n one¬AnEntity;s` failed it although Next keeps that
space: the compiler leaves unknown names as written and only a decoded
entity triggers the drop. Probing Next 16.2.6's SWC with 2,425 candidate
names (TypeScript's JSX table, the HTML5 names, case variants) showed it
decodes exactly TypeScript's 253 names, case-sensitively, plus decimal
and lowercase-x hex references with at most nine characters between &
and ;. The guard now reads entities that way. A new test compiles every
listed name and a set of near misses and requires the guard to agree with
the compiler on each; rule cases add an unknown name and a miscased one
(space kept, not flagged) and a named, decimal and hex entity (flagged).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Flag every JSX text whose edge whitespace Next's compiler drops
The guard required a previous sibling and a literal LF, and looked only
at leading spaces, so it passed three shapes Next 16.2.6's SWC mangles:
a text that opens an element (`before<span> after\n one's</span>`
renders "beforeafter one's"), a lone CR or U+2028 as the line break, and
an encoded line break at a text's edge (`{x} word\n next` renders
"{x}word next"). Probing the compiler showed two mechanisms. Next deletes
the leading spaces and tabs of a text that has a decoded entity and any
line break, literal or encoded; @swc/core 1.16.22 keeps them. Every SWC
probed also reads an encoded line break as a source line break, so at
either end of a text it vanishes with the whitespace around it, where
TypeScript and Bun keep it. Whitespace the compiler never trims ( ,
, a literal no-break space) keeps the words apart in both.
The guard now reads each text as the compiler does and applies both
rules, stated in the test's header. New rule cases cover each shape and
the kept-whitespace exceptions, each compiled with Next's SWC and checked
against TypeScript's output. No text under src/ matches the wider rule,
and against main's files the guard still names exactly the five lines.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Compare Next's compiler with TypeScript on every JSX text in the guard
The spacing guard predicted dropped whitespace from a hand-fitted model of
Next's compiler, and the round-2 review found a shape the model missed: an
encoded space after a line break at the end of a text (`a'\n `),
which Next drops and TypeScript keeps. The guard now compiles each JSX text
under src/ with Next's SWC and with TypeScript and fails wherever Next shows
no whitespace at a place TypeScript does, or renders other characters, so it
no longer depends on the model. The rule cases gain the reviewer's shape and
still pin the compiler's behavior. SRC now goes through fileURLToPath, so a
checkout path with a space works. Each SWC test gets a 60-second limit.
Against src/ from before #264 the guard names exactly the five lines #264
fixed; on this head all 207 app tests pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
policybench.org renders five phrases with no space between two words:
max(0, 1 − |pred − ref| / |ref|)when the reference is nonzero"Next 16.2.6's compiler drops the leading space of a JSX text that spans more than one line and contains an HTML entity (
',’). It keeps the space when the same text sits on one line or has no entity. #262 added the entity to the /expand sentence; the four home-page phrases predate it.This branch moves each of the five spaces into an explicit
{" "}, which the compiler emits as its own child. No word of the copy changes.This PR takes the page edits from #263, so the fix can go live before the guard test. An independent review of #263 at 782b38f found that the five edits keep every word and punctuation mark and restore one space at each boundary. Its three findings concern the tests, which stay on #263.
Lint,
bun test testsandnext buildpassed locally on #263's head, which has the same three source files, and a scan of the 73 built pages found no word running into the next.🤖 Generated with Claude Code