TeX Math
Inline math goes between $` characters, and display math in fenced code
blocks with the info string math:
Example 1
$ comrak -e math-code -t commonmark -t xml
Let x and y be integers such that
x=y + 2
Let x and y be integers such that
x=y + 2
Let
x
and
y
be integers such that
x=y + 2
In inline math, it behaves just like inline code:
Example 2
$ comrak -e math-code -t commonmark -t xml
This is math:2000.
This is math:2000.
This is math:
2000
.
Note that math can contain embedded math:
Example 3
$ comrak -e math-code -t commonmark -t xml
This is display math:
\text{Hello $x^2$}
And this is inline math:
\text{Hello $x$ there!}
This is display math:
\text{Hello $x^2$}
And this is inline math:
\text{Hello $x$ there!}
This is display math:
\text{Hello $x^2$}
And this is inline math:
\text{Hello $x$ there!}
Dollar signs are not required to be escaped with backslashes. They may be required to render the math properly, but it’s not required for parsing:
Example 4
$ comrak -e math-code -t commonmark -t xml
\text{$}
\text{$}
\text{$}
Everything inside the math construct is treated as math, and not given its normal CommonMark meaning:
Example 5
$ comrak -e math-code -t commonmark -t xml
b<a>c
b<a>c
b<a>c
Double dollar signs are not supported:
Example 6
$ comrak -e math-code -t commonmark -t xml
$$1 + 2$$
$$1 + 2$$
$$
1 + 2
$$