Skip to content

Commit cf0933c

Browse files
committed
test: pin the brace-aware template-hole strip with its own fixture
The hole strip shipped with no counterfactual: reverting it alone left every corpus walk and all four new fixtures green, because the only observable difference is two corpus lines nothing asserted. Add the fixture, which reds on the old regex. Also correct the plainText doc comment. It named … as motivating the second whitespace collapse, but that decodes to '...', which is not whitespace. Only   motivates it.
1 parent 6278a01 commit cf0933c

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

website/lib/docs-llms.server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ function oneLine(s: string): string {
140140
* decode. Exported for the same reason `bodyToMarkdown` is, so a unit test
141141
* can drive it on a fixture instead of planting scaffolding in a real docs
142142
* page. The whitespace collapse is re-run after decoding because ` `
143-
* and `…` only become whitespace-relevant once decoded.
143+
* decodes to a literal space, so a run of them is only collapsible once the
144+
* decode has happened.
144145
*/
145146
export function plainText(s: string): string {
146147
return decodeEntities(oneLine(s)).replace(/\s+/g, ' ').trim();

website/test/ssr/docs-llms.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,16 @@ test('an escaped tag in prose survives to the corpus', () => {
164164
assert.equal(md, 'a value with <code> here');
165165
});
166166

167+
test('a nested template hole leaves no debris behind', () => {
168+
// The hole strip used to be `\$\{[^}]*\}`, which stops at the FIRST `}`, so
169+
// the nested hole /docs/architecture authors left `"}` in the prose. It was
170+
// invisible while the runaway strip above deleted the whole fragment, and
171+
// reader-visible once the decode ordering was fixed, which is why the two
172+
// ship together.
173+
const md = bodyToMarkdown('html`<p>a <code>&lt;form action=${"${createPost}"}&gt;</code> posts</p>`');
174+
assert.equal(md, 'a <form action=> posts');
175+
});
176+
167177
test('plainText strips tags before it decodes entities', () => {
168178
assert.equal(plainText('a value with &lt;code&gt; here'), 'a value with <code> here');
169179
assert.match(plainText('intercepts same-origin &lt;a&gt; clicks'), /same-origin <a> clicks/);

0 commit comments

Comments
 (0)