【发布时间】:2017-05-10 00:38:49
【问题描述】:
与
rst2html5.py foo.rst --math-output=MathJax > foo.html
foo.rst 在哪里,例如
The area of a circle is :math:`A_\text{c} = (\pi/4) d^2`.
.. math::
\frac{ \sum_{t=0}^{N}f(t,k) }{N}
我得到一个独立的 html 页面foo.html。如果我只是想要 html 的主体,例如以便我可以插入另一个 html 模板?
我知道我可以做类似的事情
from docutils import core
text = open('foo.rst').read()
document = core.publish_parts(text, writer_name='html5')
然后得到document['body'],但这并不以MathJax方式处理数学指令
即我希望这个身体是
<p>The area of a circle is <span class="math">\(A_\text{c} = (\pi/4) d^2\)</span>.</p>
<div class="math">
\begin{equation*}
\frac{ \sum_{t=0}^{N}f(t,k) }{N}
\end{equation*}
</div>
而不是通常的
<p>The area of a circle is <span class="formula"><i>A</i><sub><span class="text">c</span></sub> = (<i>π</i> ⁄ 4)<i>d</i><sup>2</sup></span>.</p>
<div class="formula">
<span class="fraction"><span class="ignored">(</span><span class="numerator"><span class="limits"><sup class="limit"><i>N</i></sup><span class="limit">⎲</span><span class="limit">⎳</span><sub class="limit"><i>t</i> = 0</sub></span><i>f</i>(<i>t</i>, <i>k</i>)</span><span class="ignored">)/(</span><span class="denominator"><i>N</i></span><span class="ignored">)</span></span>
</div>
【问题讨论】:
标签: python python-sphinx restructuredtext docutils