prosemirror-math icon indicating copy to clipboard operation
prosemirror-math copied to clipboard

InputRules should ignore escaped `$` symbols

Open benrbray opened this issue 3 years ago • 2 comments

I write many more LaTeX equations than dollar amounts, but I recognize that I am in the minority. For accessibility, prosemirror-math should have a standard (but configurable) way of escaping $ characters.

At the moment, the default inline input rule uses a negative-lookbehind regex to avoid inserting math nodes, but this has a few limitations:

  • Negative lookbehinds are currently only supported in new-ish versions of Chrome and FireFox
  • Sometimes, the input rules will accidentally latch on to a $ symbol in a distant node and assume the user wants to create a math block.

Solutions to consider:

  • Modify ProseMirror's InputRule implementation to support escape sequences before a matched string
  • By default, prosemirror-math should assume all $'s are math-related, unless the user explicitly indicates otherwise. For example, any of the following actions should create an escaped $
    • use a backslash \$ to escape math
    • or put a space after the dollar sign $ to escape math (automaticaly remove the space)

benrbray avatar Mar 27 '21 10:03 benrbray

Related to #2 .

benrbray avatar Mar 27 '21 10:03 benrbray