Fixes #223 properly (one corner case has been unnoticed/hidden due test suite normalization feature). Fixes #230 (strictly speaking duplicate of the corner case).
75 lines
1.7 KiB
Text
75 lines
1.7 KiB
Text
|
|
# LaTeX Math
|
|
|
|
With the flag `MD_FLAG_LATEXMATHSPANS`, MD4C enables extension for recognition
|
|
of LaTeX style math spans.
|
|
|
|
A math span is is any text wrapped in dollars or double dollars (`$...$` or
|
|
`$$...$$`).
|
|
|
|
```````````````````````````````` example
|
|
$a+b=c$ Hello, world!
|
|
.
|
|
<p><x-equation>a+b=c</x-equation> Hello, world!</p>
|
|
.
|
|
--flatex-math
|
|
````````````````````````````````
|
|
|
|
However the LaTeX math spans cannot be nested:
|
|
|
|
```````````````````````````````` example
|
|
$$foo $bar$ baz$$
|
|
.
|
|
<p>$$foo <x-equation>bar</x-equation> baz$$</p>
|
|
.
|
|
--flatex-math
|
|
````````````````````````````````
|
|
|
|
The opening delimiter cannot be preceded with an alphanumerical character:
|
|
|
|
```````````````````````````````` example
|
|
x$a+b=c$
|
|
.
|
|
<p>x$a+b=c$</p>
|
|
.
|
|
--flatex-math
|
|
````````````````````````````````
|
|
|
|
Similarly the closing delimiter cannot be followed with an alphanumerical character:
|
|
|
|
```````````````````````````````` example
|
|
$a+b=c$x
|
|
.
|
|
<p>$a+b=c$x</p>
|
|
.
|
|
--flatex-math
|
|
````````````````````````````````
|
|
|
|
If the double dollar sign is used, the math span is a display math span.
|
|
|
|
```````````````````````````````` example
|
|
This is a display equation: $$\int_a^b x dx$$.
|
|
.
|
|
<p>This is a display equation: <x-equation type="display">\int_a^b x dx</x-equation>.</p>
|
|
.
|
|
--flatex-math
|
|
````````````````````````````````
|
|
|
|
Math spans may span multiple lines as they are normal spans:
|
|
|
|
```````````````````````````````` example
|
|
$$
|
|
\int_a^b
|
|
f(x) dx
|
|
$$
|
|
.
|
|
<p><x-equation type="display"> \int_a^b f(x) dx </x-equation></p>
|
|
.
|
|
--flatex-math
|
|
````````````````````````````````
|
|
|
|
Note though that many (simple) renderers may output the math spans just as a
|
|
verbatim text. (This includes the HTML renderer used by the `md2html` utility.)
|
|
|
|
Only advanced renderers which implement LaTeX math syntax can be expected to
|
|
provide better results.
|