I’m encountering a rendering issue with inline MathJax in Discourse when the math expression is followed by a curly apostrophe (U+2019), which is commonly substituted by smart quotes in some browsers or editors.
This renders correctly:
$\mathbb{R}^2$'s basis
This uses the straight ASCII apostrophe (U+0027).
\mathbb{R}^2's basis
This fails to render:
$\mathbb{R}^2$’s basis
$\mathbb{R}^2$’s basis
This uses the curly right single quote (U+2019), sometimes auto-inserted by mobile keyboards, rich text editors, or copy/paste from formatted sources.
Expected behavior:
Both versions should render the math properly. The character immediately following an inline math block shouldn’t affect MathJax parsing.
Why this matters:
This is hard to detect unless you’re comparing Unicode.
The curly apostrophe is visually indistinguishable from the straight one in most fonts.
A minor formatting difference like this shouldn’t silently break rendering.
Inconsistent behavior undermines the authoring experience for math-heavy posts.
So, I think your simple solution is to always put a space after the closing $.
I’m pretty sure that this is the expected behavior and am surprised that my decades old knowledge still seems to work, but that’s why the TeX version number approaches \pi.
Well, there’s still that annoying extra space if you put a space. And a period after the closing dollar works as expected.
I’m back to thinking that maybe I don’t know what the expected behavior is and I’m not willing to try to render TeX from my phone.