Like other inline markup, whitespace immediately after opening is not allowed . foo$ 1+1 = 2$ bar .

foo$ 1+1 = 2$ bar

. Neither is whitespace immediately before closing . foo $1+1 = 2 $bar .

foo $1+1 = 2 $bar

.