Skip to content

Commit 2c75136

Browse files
committed
ENH: Support MathJax inline $dollar-pattern$
Fixes #410
1 parent 56bbc9c commit 2c75136

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

pdoc/templates/html.mako

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@
411411
% endif
412412

413413
% if latex_math:
414+
<script type="text/x-mathjax-config">MathJax.Hub.Config({ tex2jax: { inlineMath: [ ['$','$'], ["\\(","\\)"] ], processEscapes: true } });</script>
414415
<script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS_CHTML" integrity="sha256-kZafAc6mZvK3W3v1pHOcUix30OHQN6pU/NO2oFkqZVw=" crossorigin></script>
415416
% endif
416417

pdoc/test/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,6 +1665,8 @@ def test_latex_math(self):
16651665
expected = r'''<p>Inline equation: <span><span class="MathJax_Preview"> v_t *\frac{1}{2}* j_i + [a] &lt; 3 </span><script type="math/tex"> v_t *\frac{1}{2}* j_i + [a] < 3 </script></span>.</p>
16661666
<p>Block equation: <span><span class="MathJax_Preview"> v_t *\frac{1}{2}* j_i + [a] &lt; 3 </span><script type="math/tex; mode=display"> v_t *\frac{1}{2}* j_i + [a] < 3 </script></span></p>
16671667
<p>Block equation: <span><span class="MathJax_Preview"> v_t *\frac{1}{2}* j_i + [a] &lt; 3 </span><script type="math/tex; mode=display"> v_t *\frac{1}{2}* j_i + [a] < 3 </script></span></p>
1668+
<p>$\mathcal{O}(N)$</p>
1669+
<p>Escaping \$ should work in math like $X = \$3.25$ once it is implemented.</p>
16681670
<p><span><span class="MathJax_Preview"> v_t *\frac{1}{2}* j_i + [a] &lt; 3 </span><script type="math/tex; mode=display"> v_t *\frac{1}{2}* j_i + [a] < 3 </script></span></p>''' # noqa: E501
16691671
text = inspect.getdoc(self._docmodule.latex_math)
16701672
html = to_html(text, module=self._module, link=self._link, latex_math=True)

0 commit comments

Comments
 (0)