Dollar signs in prompts are being misinterpreted by KaTeX #186
Labels
🗂 Bug
Type: Technical defect, not functioning as designed
🚩 Help wanted
Particularly amenable/appropriate for contributors
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.The text was updated successfully, but these errors were encountered: