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

Dollar signs in prompts are being misinterpreted by KaTeX #186

Open
andymatuschak opened this issue Mar 1, 2021 · 0 comments
Open

Dollar signs in prompts are being misinterpreted by KaTeX #186

andymatuschak opened this issue Mar 1, 2021 · 0 comments
Labels
🗂 Bug Type: Technical defect, not functioning as designed 🚩 Help wanted Particularly amenable/appropriate for contributors

Comments

@andymatuschak
Copy link
Owner

andymatuschak commented Mar 1, 2021

This prompt text is mis-parsed by KaTeX: If you have $1 then what is $x+2$?. It interprets $1 as the beginning of an inline math expression. This is understandable, I suppose, but unfortunate! n.b. this only causes problems if there is also an inline TeX expression in the line. What is $1 in pesos? is fine.

Unfortunately, the upstream bug has been open a while: KaTeX/KaTeX#437

I'm not sure what the appropriate resolution is here. MathJax can parse \$ as dollar signs rather than inline TeX delimeters. We need to migrate to MathJax anyway for mobile LaTeX support (#153), so perhaps we'll migrate to MathJax for the web, too.

But is that really the best solution? To escape dollar signs in our data structures all the time? We can avoid exposing this in the interface by having our interfaces, importers, etc escape user-inserted dollar signs. Unless we allow them to type inline math expressions also using dollar signs. And this means that anyone interacting with our API also has to worry about this.

As an alternative, perhaps we should consider different math delimiters: \( x^2 \) is the LaTeX syntax of choice, though it's certainly less pleasant for authors. If we want to go this way, we need to think through what happens to all the existing prompts "in the wild." Thankfully, there aren't too many of them. So we could whitelist for the small number of domains using the dollar-based syntax, while we ask those authors to "move over" to the new syntax. Then we need to migrate existing users' prompt references with a backfill script.

@andymatuschak andymatuschak added the 🗂 Bug Type: Technical defect, not functioning as designed label Mar 1, 2021
@andymatuschak andymatuschak added the 🚩 Help wanted Particularly amenable/appropriate for contributors label Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗂 Bug Type: Technical defect, not functioning as designed 🚩 Help wanted Particularly amenable/appropriate for contributors
Projects
None yet
Development

No branches or pull requests

1 participant