Skip to content

fix(remend): drop lookbehind from single-tilde pattern for Safari < 16.3 - #576

Open
s-andringa wants to merge 1 commit into
vercel:mainfrom
s-andringa:fix/issue-519-lookbehind-safari-16
Open

fix(remend): drop lookbehind from single-tilde pattern for Safari < 16.3#576
s-andringa wants to merge 1 commit into
vercel:mainfrom
s-andringa:fix/issue-519-lookbehind-safari-16

Conversation

@s-andringa

Copy link
Copy Markdown

Refs #519.

What

Removes the lookbehind assertion from remend's single-tilde escape pattern:

-const SINGLE_TILDE_PATTERN = /(?<=[\p{L}\p{N}_])~(?!~)(?=[\p{L}\p{N}_])/gu;
+const SINGLE_TILDE_PATTERN = /([\p{L}\p{N}_])~(?!~)(?=[\p{L}\p{N}_])/gu;

The preceding word character is now captured and written back in the replacement, and the offset handed to isInsideCodeBlock is shifted by its length so it still points at the ~. Semantics are unchanged — Unicode support (\p{L}, \p{N}, so CJK and other scripts) is fully preserved.

Why

JSCore on iOS 16.0–16.2 / Safari < 16.3 does not support lookbehind and throws SyntaxError: Invalid regular expression: invalid group specifier name. Because the pattern is a module-level constant, this throws during module evaluation — before any user code runs — so the whole chunk fails to export and the page goes blank. There is no way for a consumer to catch it. Safari only shipped lookbehind in 16.4 (caniuse).

Scope

This PR deliberately only fixes remend. #519 identifies a second lookbehind in mdast-util-gfm-autolink-literal@2, pulled in via remark-gfm@4. That one is not addressed here, because the maintainer has stated the lookbehind is intentional and will not be changed: syntax-tree/mdast-util-gfm-autolink-literal#10 (comment). Projects needing full iOS 16.0–16.2 support will have to patch that dependency themselves (pnpm patch / patch-package).

So this change does not single-handedly close #519 for every streamdown consumer. It does fix it outright for anyone depending on remend directly, without dragging in remark-gfm — which is my own use case, and the one bit of this that is squarely this repo's own code rather than a third party's.

Testing

  • pnpm --filter remend test — 458/458 pass, no changes needed to existing tests (behaviour is identical)
  • pnpm --filter streamdown test — 991/991 pass
  • pnpm check — clean
  • Built dist output verified free of any (?< occurrences

Changeset included (remend, patch).

@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Someone is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@s-andringa
s-andringa marked this pull request as ready for review August 12, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streamdown crashes on iOS 16 / Safari < 16.3 due to lookbehind regex in remend and mdast-util-gfm-autolink-literal

1 participant