Skip to content

fix: allow math in rst #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion readme_renderer/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def emptytag(

# Output math blocks as LaTeX that can be interpreted by MathJax for
# a prettier display of Math formulas.
"math_output": "MathJax",
# Pass a dummy path to supress docutils warning and emit HTML.
"math_output": "MathJax /dummy.js",

# Disable raw html as enabling it is a security risk, we do not want
# people to be able to include any old HTML in the final output.
Expand Down
8 changes: 8 additions & 0 deletions tests/fixtures/test_rst_math.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<p>A <tt>math</tt> directive:</p>
<div class="math">
\begin{equation*}
\alpha _t(i) = P(O_1, O_2, \ldots O_t, q_t = S_i \lambda )
\end{equation*}
</div>
<p>A <tt>:math:</tt> role:</p>
<p>The area of a circle is <span class="math">\(A_\text{c} = (\pi/4) d^2\)</span>.</p>
14 changes: 14 additions & 0 deletions tests/fixtures/test_rst_math.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. Sample from https://docutils.sourceforge.io/docs/ref/rst/directives.html#math

A ``math`` directive:

.. math::

α_t(i) = P(O_1, O_2, … O_t, q_t = S_i λ)


.. Sample from https://docutils.sourceforge.io/docs/ref/rst/roles.html#math

A ``:math:`` role:

The area of a circle is :math:`A_\text{c} = (\pi/4) d^2`.