Problem#
The bundled Markdown renderer (Words) accepts non-ASCII whitespace such as nonbreaking spaces (U+00A0) inside footnote labels (for example, [^a\u00a0b]), rendering them as numbered footnotes when given the whole document. In long Markdown files split by splitMarkdown (packages/shared/src/markdownChunks.ts), FOOTNOTE_DEFINITION_START, CONTAINED_PREFIX, and extractFootnoteRefs use JavaScript \s as a label boundary, which rejects U+00A0 (and other Unicode whitespace) and drops both the definition and reference so the preview renders the literal citation text instead of a linked footnote.
Steps to reproduce (zero sign-in required):
- Open a Markdown file longer than one chunk (>4,500 characters) containing
[^a\u00a0b] (with U+00A0) in the first chunk and [^a\u00a0b]: Shared note. at the bottom in Files -> Show rendered markdown (or run vp test run packages/shared/src/markdownChunks.test.ts -t "matches footnote citations").
- Expected:
splitMarkdown emits stubs: "[^a\u00a0b]: ." and links both citations and back-links to the footnote section, matching Words on the unchunked document.
- Actual on
main: splitMarkdown drops the footnote (footnotes is undefined) and renders the literal [^a\u00a0b] text.
Change#
Replace \s with ASCII whitespace [ \t-\r] (and \\. with \\[^\r\n] in the two definition regexes so escaped U+2028/U+2029 match Words too) across all three footnote-label scanners in packages/shared/src/markdownChunks.ts (FOOTNOTE_DEFINITION_START, CONTAINED_PREFIX, and extractFootnoteRefs) so they stay in step and match Words across all ASCII and Unicode whitespace characters.
Scope#
Small bug fix for a chunk-scanner mismatch with Words on non-ASCII whitespace in footnote labels, so no separate issue. Touches only packages/shared/src/markdownChunks.ts and adds one NBSP row to the existing citation table in packages/shared/src/markdownChunks.test.ts. Does not change product defaults, contracts, or ASCII whitespace handling.
Verification#
- Base (
c91360fc96): vp test run packages/shared/src/markdownChunks.test.ts -t "matches footnote citations" failed on the new NBSP row with AssertionError: expected undefined to be '[^a b]: .'.
- Head (
be061ae1d6, rebased onto latest origin/main): vp env exec --node 26.13.1 vp test run packages/shared/src/markdownChunks.test.ts passed 205/205 tests.
- Combined
vp env exec --node 26.13.1 vp run check:changed passed on the identical commit diff (format, lint, knip, typecheck across 37 packages, test 200/200).
- Parity probe against Words across 14 whitespace characters (bare and escaped, 28 cases total) confirmed 28/28 exact agreement.
- Not checked: live interactive rendering in desktop or mobile clients (both consume the shared
splitMarkdown chunker).
Evidence#
Seed notes.md with '# First', 'First[^a\u00a0b] near the beginning.', a roughly 5,000-character lorem paragraph, '# Second', 'Again[^a\u00a0b]', and '[^a\u00a0b]: Shared note.' (three real U+00A0 characters). Seed control.md with label 'ab'. Open the thread, expand its file citations, open notes.md in the Files viewer and choose Show rendered markdown. Capture the first citation, scroll to Second and the footnote, click the first backlink, then open control.md and capture its first citation. Repeat identically on both commits.
Environment for every capture: real web client in Chromium, 1280×800, light theme; separate commit checkouts and fresh databases seeded through the scenario API with Replay (dev).
Base leaves the first NBSP citation literal, with one citation link and one backlink. Head renders both citation links and both backlinks; clicking the first backlink returns to First. The plain-label control links on both.
Scenario driver and synthetic seed