Simple inline math . $1+1 = 2$ .

1+1=21+1 = 2

. Simple block math . $$1+1 = 2$$ . 1+1=21+1 = 2 . No whitespace before and after is fine . foo$1+1 = 2$bar .

foo1+1=21+1 = 2bar

. Even when it starts with a negative sign . foo$-1+1 = 2$bar .

foo1+1=2-1+1 = 2bar

. Shouldn't render empty content . aaa $$ bbb .

aaa $$ bbb

. Shouldn't render USD . aaa $5.99 bbb .

aaa $5.99 bbb

. Shouldn't render trailing delimiter . aaa 5.99$ bbb .

aaa 5.99$ bbb

. Paragraph break in inline math is not allowed . foo $1+1 = 2$ bar .

foo $1+1

= 2$ bar

. Neither is an end of document . foo $1+1 = 2 .

foo $1+1 = 2

. Inline math with apparent markup . foo $1 *i* 1$ bar .

foo 1i11 *i* 1 bar

. Block math can be indented up to 3 spaces . $$ 1+1 = 2 $$ . 1+1=21+1 = 2 . But 4 means a code block . $$ 1+1 = 2 $$ .
$$
1+1 = 2
$$
. Multiline inline math . foo $1 + 1 = 2$ bar .

foo 1+1=21 + 1 = 2 bar

. Multiline display math . $$ 1 + 1 = 2 $$ . 1+1=2 1 + 1 = 2 . Text can immediately follow inline math . $n$-th order .

nn-th order

. Display math self-closes at the end of document . $$ 1+1 = 2 . 1+1=21+1 = 2 . Display and inline math can appear in lists . * $1+1 = 2$ * $$ 1+1 = 2 $$ . . Display math can be written in one line . $$1+1 = 2$$ . 1+1=21+1 = 2 . Or on multiple lines with expression starting and ending on delimited lines . $$[ [1, 2] [3, 4] ]$$ . [[1,2][3,4]][ [1, 2] [3, 4] ] . Escaped delimiters should not render math . Foo \$1$ bar \$\$ 1 \$\$ .

Foo $1$ bar $$ 1 $$

.