GitHub math bugs

Math on GitHub is buggy. (See my blog posts [https://nschloe.github.io/2022/05/20/math-on-github.html, https://nschloe.github.io/2022/06/27/math-on-github-follow-up.html] posts about it.)

To keep track of what's working and what isn't, I've created this repo with some MWEs. If you have any more examples, let me know or PR!

Inline and display math in same list item doesn't render

- $`a`$

  ```math
  a
  ```

- ```math
  b
  ```
  • $a$

    a
    
  • b
    

Inline and display math in <details>

<details>

$`A = 5`$
```math
A = 5
```
</details>

$A = 5$

A = 5

< without surrounding whitespace

$`a<b`$

```math
a<b
```

$a&lt;b$

$$a<b$$

Math doesn't render in footnotes

[^a]

[^a]: Lorem $`a`$

1

Math doesn't render in links

[$`a`$](x)

$a$

Math doesn't render if preceeded by an alphabetic character

a$`x`$

-$`x`$

1$`x`$

a$x$

-$x$

1$x$

Inline math with %\n

$`a+%
b`$

$a+% b$

Comments before bracket delimiters

```math
\left%
(a+b\right)
```
$$\left% (a+b\right)$$

Sum/product signs in inline mode or fractions

$`f(x) = \sum_{i=0}^{n} \prod_{j=0}^{n} a_{i,j}`$

```math
\frac{\sum_{i=1}^n a_i \prod_{i=1}^n b_i}{2}
```

$f(x) = \sum_{i=0}^{n} \prod_{j=0}^{n} a_{i,j}$

$$\frac{\sum_{i=1}^n a_i \prod_{i=1}^n b_i}{2}$$

\operatorname not working

```math
\operatorname*{Min}_{x}
```
$$\operatorname*{Min}_{x}$$

Inline math at the end of italic text

_$`a`$ equals $`b`$_

*$`a`$ equals $`b`$*

**$`a`$ equals $`b`$**

$a$ equals $b$

$a$ equals $b$

$a$ equals $b$

Dollar in \text

```math
a
```

- ```math
  \text{$b$}
  ```
$$a$$
  • \text{$b$}
    

50 or more colors in a block

49 colors:

$$10: {\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a} 10: {\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a} 10: {\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a} 10: {\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a} 9: {\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}$$

50 colors:

```math
10:  {\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}
10:  {\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}
10:  {\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}
10:  {\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}
10:  {\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}
```
$$10: {\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a} 10: {\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a} 10: {\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a} 10: {\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a} 10: {\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}{\color{red}a}$$

100 or more bracketed exponents or subscripts

```math
a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10}
a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10}
a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10}
a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10}
a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10}
a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10}
a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10}
a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10}
a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10}
a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10}
```
$$a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10} a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10} a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10} a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10} a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10} a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10} a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10} a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10} a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10} a^{1} a^{2} a^{3} a^{4} a^{5} a^{6} a^{7} a^{8} a^{9} a^{10}$$

Backslashes in $-math

$\{a\,b\}$

${a,b}$

Fixed by using backtick delimiters:

$\{a\,b\}$

Math vs. HTML mix-up

$a <b > c$

$[(a+b)c](d+e)$

${a}_b c_{d}$

$a c$

$(a+b)c$

${a}b c{d}$

Some fixed by using backtick delimiters:

$a &lt;b &gt; c$

$[(a+b)c](d+e)$

${a}_b c_{d}$

Dollar-math with spaces

This is the example from GitHub's announcement blog post.

When $a \ne 0$, there are two solutions to $(ax^2 + bx + c = 0)$ and they are
$$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$

When $a \ne 0$, there are two solutions to $(ax^2 + bx + c = 0)$ and they are $$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$

Fixed by using backtick delimiters:

When $a \ne 0$, there are two solutions to $(ax^2 + bx + c = 0)$ and they are

$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}$$

Spacing around dollar sign in math mode

$x = \$$

$x = $$

Fixed by using backtick delimiters:

$x = \$$

Math in italic text

_Equation $\Omega(69)$ in italic text_

Equation $\Omega(69)$ in italic text

Fixed by using backtick delimiters:

Equation $\Omega(69)$ in italic text

Inline math can't be preceded by brackets, quotation marks etc.

$\pi$
'$\pi$
"$\pi$
($\pi$
[$\pi$
{$\pi$
/$\pi$

$\pi$ '$\pi$ "$\pi$ ($\pi$ [$\pi$ {$\pi$ /$\pi$

Fixed by using backtick delimiters:

$\pi$ '$\pi$ "$\pi$ ($\pi$ [$\pi$ {$\pi$ /$\pi$

Oversized sqrt symbol around fractions

```math
\sqrt{\frac{1}{2}}
```
$$\sqrt{\frac{1}{2}}$$

Matrices without line breaks in $$-math

$$
\begin{pmatrix}a & b\\ c & d\end{pmatrix}
$$

$$ \begin{pmatrix}a & b\ c & d\end{pmatrix} $$

What works: Using triple-backtick delimiters, or inserting a linebreak after the \\.

$$\begin{pmatrix}a & b\\ c & d\end{pmatrix}$$

Footnotes

  1. Lorem $a$