数学公式扩展(Markdig 规范文档)
添加对数学片段的支持:
数学内联
允许使用 $...$
定义数学块:
This is a $math block$
.
<p>This is a <span class="math">\(math block\)</span></p>
或者使用 $$...$$
包裹它:
This is a $$math block$$
.
<p>This is a <span class="math">\(math block\)</span></p>
内联数学中不允许有换行符:
This is not a $$math
block$$ and? this is a $$math block$$
.
<p>This is not a $$math
block$$ and? this is a <span class="math">\(math block\)</span></p>
This is not a $math
block$ and? this is a $math block$
.
<p>This is not a $math
block$ and? this is a <span class="math">\(math block\)</span></p>
如果关闭的 $
前面也有空格,那么开头的 $
后面可以跟一个空格:
This is a $ math block $
.
<p>This is a <span class="math">\(math block\)</span></p>
This is a $ math block $ after
.
<p>This is a <span class="math">\(math block\)</span> after</p>
This is a $$ math block $$ after
.
<p>This is a <span class="math">\(math block\)</span> after</p>
This is a not $ math block$ because there is not a whitespace before the closing
.
<p>This is a not $ math block$ because there is not a whitespace before the closing</p>
对于开头的 $
,它需要前面有一个空格或标点符号(但不能在单词内部使用):
This is not a m$ath block$
.
<p>This is not a m$ath block$</p>
对于结尾的 $
,它需要后面有一个空格或标点符号(但不能前面有空格,也不能在单词内部使用):
This is not a $math bloc$k
.
<p>This is not a $math bloc$k</p>
对于结尾的 $
,它需要后面有一个空格或标点符号(但不能前面有空格,也不能在单词内部使用):
This is should not match a 16$ or a $15
.
<p>This is should not match a 16$ or a $15</p>
可以使用转义字符 \\
在数学内联块之间插入 $
:
This is a $math \$ block$
.
<p>This is a <span class="math">\(math \$ block\)</span></p>
最多只能匹配两个 $
作为开头和结尾:
This is a $$$math block$$$
.
<p>This is a <span class="math">\($math block$\)</span></p>
常规文本可以在数学内联前后出现:
This is a $math block$ with text on both sides.
.
<p>This is a <span class="math">\(math block\)</span> with text on both sides.</p>
数学块优先于标准强调符号 *
和 _
:
This is *a $math* block$
.
<p>This is *a <span class="math">\(math* block\)</span></p>
行首的 $$
不应解释为数学块:
$$ math $$ starting at a line
.
<p><span class="math">\(math\)</span> starting at a line</p>
数学块
数学块可以通过在行首使用 $$
跨多行。它工作原理类似于围栏代码块。
$$
\begin{equation}
\int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
\label{eq:sample}
\end{equation}
$$
.
<div class="math">
\[
\begin{equation}
\int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
\label{eq:sample}
\end{equation}
\]</div>