Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InputRules should ignore escaped $ symbols #10

Open
benrbray opened this issue Mar 27, 2021 · 2 comments
Open

InputRules should ignore escaped $ symbols #10

benrbray opened this issue Mar 27, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@benrbray
Copy link
Owner

benrbray commented Mar 27, 2021

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 benrbray added the bug Something isn't working label Mar 27, 2021
@benrbray benrbray changed the title Allow Escaped InputRules should ignore escaped $ symbols Mar 27, 2021
@benrbray
Copy link
Owner Author

Related to #2 .

@Kroid
Copy link

Kroid commented Aug 24, 2024

Lookbehind now supports in most browsers: https://caniuse.com/js-regexp-lookbehind (93%+ of all users).
I think, you can update readme section https://github.com/benrbray/prosemirror-math?tab=readme-ov-file#input-rules for use REGEX_INLINE_MATH_DOLLARS_ESCAPED or add link to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants