discourse-mathjax icon indicating copy to clipboard operation
discourse-mathjax copied to clipboard

Inline MathJax accidentally trigger when talking about money

Open AccaliaDeElementia opened this issue 9 years ago • 3 comments

When fed the raw text:

[quote]It costs a lot of money for Soldiers to train on an M1 Abrams tank. Not only does it cost about $67 per mile to operate, but Sabot ammunition rounds cost about $1,175 each, and HEAT rounds cost about $830 each.[/quote]

MathJax will be triggered for this substring: $67 per mile to operate, but Sabot ammunition rounds cost about $

This is unexpected and confusing, paticularly because it is difficult to prevent. I would expect that the inline mathjax would enforce a word boundary before and after the inline section. Or expressed Via Regex: /\b$[^$]+$\b/

Examples: https://what.thedailywtf.com/t/lighting-logic/2754/9?u=accalia https://what.thedailywtf.com/t/mathjax-playground/50449/10?u=accalia

AccaliaDeElementia avatar Aug 07 '15 12:08 AccaliaDeElementia

If it matters, the configuration is currently the default:

mathjax url: //cdn.mathjax.org/mathjax/latest/MathJax.js mathjax config: TeX-AMS-MML_HTMLorMML

pauljherring avatar Aug 07 '15 12:08 pauljherring

The dollar-sing delimiters are not enabled in MathJax by default for just this reason. If dollar signs are being processed, that would have to be due to your configuration adding them as inline math delimiters. Your page no longer loads MathJax, so I can't check the configuration, but one way to avoid the problem is to not enable dollar signs as delimiters. If you enable dollar-sign delimiters it is customary also to enable processEscapes so that you can use \$ to prevent the dollar from being treated as a delimiter.

Note that your suggested regular expression will not help, since /\b$/ is true for any dollar sign (the dollar sign is itself a word break).

dpvc avatar Aug 15 '15 12:08 dpvc

at would have to be due to your configuration adding them as inline math delimiters.

As pointed out on the other bug, and in my comment from 10 days ago, it's not at all clear where such configuration options are actually... configured, for Discourse.

pauljherring avatar Aug 17 '15 11:08 pauljherring