[Bug] Invalid Regular Expression on Safari (iOS)
Initial checklist
- [x] I agree to follow the code of conduct
- [x] I searched issues and discussions and couldn’t find anything (or linked relevant results below)
Affected packages and versions
v7.6.3
Link to runnable example
No response
Steps to reproduce
mdast-util-gfm-autolink-literal package uses a lookbehind assertion which is not fully supported in Safari iOS. It causes the component to not render (the Milkdown Editor). This package is used by remark itself. I ended up tracing it through the package chains but I don't have it exactly. In any case, this is likely to cause a problem. @wenxue11 has a forked repo you can override for now: https://github.com/wenxue11/mdast-util-gfm-autolink-literal
I wanted to post it as an issue for anyone else looking to see a fix. I know its not something you can fix on this package (I suppose you can override too but that feels worse?) but it sems like a good idea to document the issue and present a solution.
How to override in pnpm (though maybe fork wenxue11's repo)
"pnpm": {
"overrides": {
"mdast-util-gfm-autolink-literal": "github:wenxue11/mdast-util-gfm-autolink-literal"
}
}
They have changed the regex for iOS compatability:
/** @type {FromMarkdownTransform} */
function transformGfmAutolinkLiterals(tree) {
findAndReplace(
tree,
[
[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, findUrl],
-[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, findEmail]
+[/(?:^|\s|[!"#$%&'()*+,\-./:;<=>?@[\\]^_`{|}~])([-.\\w+]+)@([-\w]+(?:\.[-\w]+)+)/gi, findEmail]
],
{ignore: ['link', 'linkReference']}
)
}
Expected behavior
For it to render the editor.
Actual behavior
Doesn't render the editor.
Runtime
Safari
OS
Other (please specify in steps to reproduce)
Build and bundle tools
Vite