Skip to content

math: render bare display environments - #2766

Closed
ridge-kimani wants to merge 1 commit into
freeCodeCamp:mainfrom
ridge-kimani:math-environments
Closed

ridge-kimani wants to merge 1 commit into
freeCodeCamp:mainfrom
ridge-kimani:math-environments

Conversation

@ridge-kimani

Copy link
Copy Markdown

Follow-up to #2752, found while regenerating the documentations listed in #2763.

Sphinx emits environments such as align* inside <div class="math"> without the \[...\] delimiters, because MathJax treats them as display math on its own. MathFilter only looked for delimiters, so those nodes stayed as raw TeX. For example, NumPy's dev/internals.code-explanations page has three of them:

<div class="math notranslate nohighlight">
\begin{align*} o[0] &amp; = &amp; i[0] \\ o[k] &amp; = &amp; i[k]\textrm{&lt;op&gt;}o[k-1]\quad k=1\ldots N. \end{align*}</div>

The filter now renders a node whose whole content is one \begin{env}...\end{env} block as display math. KaTeX supports the environments MathJax accepts outside delimiters (align, align*, gather, alignat, ...), and aligned/cases inside them.

Test added; full suite passes (832 runs). Across the regenerated scikit-learn, NumPy, Polars and Statsmodels pages this was the only kind of math left unrendered.

🤖 Generated with Claude Code

Sphinx emits environments such as align* inside <div class="math">
without the \[...\] delimiters, since MathJax treats them as display
math on its own. Render those nodes as display math too; KaTeX
supports align, align*, gather and the other environments MathJax
accepts outside delimiters.

Found on the NumPy "code explanations" page of the developer guide.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant