Skip to content

Instantly share code, notes, and snippets.

@crvdgc
Last active June 27, 2022 03:16
Show Gist options
  • Save crvdgc/8278d5fbadb6eec0c47db22552f20f6f to your computer and use it in GitHub Desktop.
Save crvdgc/8278d5fbadb6eec0c47db22552f20f6f to your computer and use it in GitHub Desktop.
Showcase and analyze a rendering error of MathJax in GitHub Markdown

GitHub Markdown MathJax rendering error

Two inlines after text will hide the text in between

where $T$ is lookback; $\tau$ is horizon.

renders to

where $T$ is lookback; $\tau$ is horizon.

No problem when line starts with an inline

$T$ is lookback; $\tau$ is horizon.

renders to

$T$ is lookback; $\tau$ is horizon.

Extra space after the content in the first inline partially solves the problem

where $T $ is lookback; $\tau$ is horizon.

renders to

where $T $ is lookback; $\tau$ is horizon.

However, notice there are no spaces between "where" and "$T$".

Another space before the first inline renders correctly

where  $T $ is lookback; $\tau$ is horizon.

renders to

where $T $ is lookback; $\tau$ is horizon.

Analysis

where $T$ is lookback; $\tau$ is horizon.

renders to

where $T$ is lookback; $\tau$ is horizon.

It seems that the above sentence is parsed to

where$T$\tau$ is horizon.

Indeed, it renders to

where$T$\tau$ is horizon.

which is exactly the same as above.

Adding spaces seems to break this interpretation. So if I have to guess, when $ is preceded by a space, it will try to "eat" that space. In this case, it erroneously extends the "eating" process into the last $.

To test out the theory, we remove the space preceding the second inline:

where $T$ is lookback;$\tau$ is horizon.

which renders (correctly) to

where $T$ is lookback;$\tau$ is horizon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment