benrbray / prosemirror-math

Schema and plugins for "first-class" math support in ProseMirror!
https://benrbray.com/prosemirror-math/
MIT License
249 stars 35 forks source link

Safari - regular expression #6

Closed amilich closed 3 years ago

amilich commented 3 years ago

Looks like safari doesn't support lookbehind yet - any alternate regex for the math_inline input rule?

benrbray commented 3 years ago

There's actually a simpler regex commented out in the code that avoids using lookbehinds, but you will lose the ability to escape $ symbols with \$.

In the future, I'll probably look for a more cross-browser-friendly way to escape.

amilich commented 3 years ago

Thank you! I've actually been testing with /[^\\]?\$([^$\n\\]+)[^\\][\$]/, which seems to work okay, and then adding 1 to start inside replaceRangeWith if the match starts with a space. Probably could be cleaner.