Skip to content

Upgrade MyST-NB to get glue:math directive to work #97

@martinlarsalbert

Description

@martinlarsalbert

Describe the bug

context

The glue:math directive is not working in JupyterBook as seen in the documentation:
https://jupyterbook.org/en/stable/content/executable/output-insert.html#the-glue-math-directive
...where the equation has no number ( ).

This seems to be a bug that has been corrected in later versions of MyST-NB:
https://myst-nb.readthedocs.io/en/latest/render/glue.html#the-glue-math-directive

But JupyterBook is not compatible with this newer version of MyST-NB as it seems.
The newer MyST-NB works for html generation but not with latex builder.

expectation

bug

$ jupyter-book build mybook --builder latex

File "E:\dev\wPCC_pipeline\venv\lib\site-packages\sphinx_jupyterbook_latex\transforms.py", line 433, in apply
from myst_nb.nodes import CellInputNode, CellOutputNode
ModuleNotFoundError: No module named 'myst_nb.nodes'

problem
Apparantly "myst_nb.nodes" does no longer exist.

I removed the failing part as a dirty fix that works for me now, as I don't have any code blocks.
But I suspect that is not a good solution for all.

   class CodeBlockTransforms(SphinxPostTransform):
    """Handling any post transforms needed for code cells."""

    default_priority = 999

    def apply(self):
        if isinstance(self.env.app.builder, builders.latex.LaTeXBuilder):
            """Wrapping myst_nb code cell nodes with nodes of this extension."""
            pass
            #from myst_nb.nodes import CellInputNode, CellOutputNode
            #
            #for node in self.document.traverse(CellOutputNode):
            #    celloutput = CellOutput()
            #    celloutput.append(node.deepcopy())
            #    node.replace_self(celloutput)
            #
            #for node in self.document.traverse(CellInputNode):
            #    cellinput = CellInput()
            #    cellinput.append(node.deepcopy())
            #    node.replace_self(cellinput)

Reproduce the bug

  1. upgrade MyST-NB
  2. jupyter-book build mybook --builder latex

List your environment

Jupyter Book : 0.12.3
External ToC : 0.2.3
MyST-Parser : 0.17.2
MyST-NB : 0.15.0
Sphinx Book Theme : 0.1.10
Jupyter-Cache : 0.5.0
NbClient : 0.5.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions