Skip to content
Open
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
15 changes: 11 additions & 4 deletions src/nbsphinx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import sphinx.directives.other
import sphinx.environment
import sphinx.errors
import sphinx.transforms
import sphinx.transforms.post_transforms.images
from sphinx.util.matching import patmatch
try:
Expand Down Expand Up @@ -1458,7 +1459,7 @@ def apply(self):
env.nbsphinx_files.setdefault(env.docname, []).append(file)


class ForceEquations(docutils.transforms.Transform):
class ForceEquations(sphinx.transforms.SphinxTransform):
"""Unconditionally enable equations on notebooks.

Except if ``nbsphinx_assume_equations`` is set to ``False``.
Expand All @@ -1468,9 +1469,15 @@ class ForceEquations(docutils.transforms.Transform):
default_priority = 900 # after checking for equations in MathDomain

def apply(self):
env = self.document.settings.env
if env.config.nbsphinx_assume_equations:
env.get_domain('math').data['has_equations'][env.docname] = True
if sphinx.version_info[:2] >= (8, 2):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity: Why are you putting [:2] there?
Shouldn't it behave identically when you drop it?

# Sphinx 8.2 detects equations via the writer/translator,
# so ForceEquations isn't needed.
return
if not self.config.nbsphinx_assume_equations:
return

maths_data = self.env.get_domain('math').data
maths_data.setdefault('has_equations', {})[self.env.docname] = True


class GetSizeFromImages(
Expand Down
Loading