executablebooks / MyST-NB

Parse and execute ipynb files in Sphinx
https://myst-nb.readthedocs.io
BSD 3-Clause "New" or "Revised" License
205 stars 84 forks source link

Problem with Ipython.display Markdown with math #636

Open WKorzen opened 3 hours ago

WKorzen commented 3 hours ago

Describe the bug

context When I do create ipynb with cell

text2 = ('Lorem ipsum $x$ lorem $A$ ipsum?\n'
           '\t\\[\n\t\t\\text{A=}\\left[\\begin{matrix}2 x + 4 & x - 4\\\\x + 1 & -1\\end{matrix}\\right]\n'
           '\t\\]\n'
           'Lorem ipsum $x=-2.$ Ipsum lorem.\n')

and

Markdown(text2.replace('\\[','$$').replace('\\]','$$'))

I receive wrong result generated by sphinx with myst_nb

image

expectation I expected like in jupyter lab image

bug But i received image

Reproduce the bug

List your environment

installed:

myst-nb                       1.1.1
myst-parser                   4.0.0
jupyter                       1.1.1
jupyter-cache                 1.0.0
jupyter_client                8.6.2
jupyter-console               6.6.3
jupyter_core                  5.7.2
jupyter-events                0.10.0
jupyter-lsp                   2.2.5
jupyter_server                2.14.2
jupyter_server_terminals      0.5.3
jupyterlab                    4.2.5
jupyterlab_pygments           0.3.0
jupyterlab_server             2.27.3
jupyterlab_widgets            3.0.13
nbsphinx                      0.9.5
sphinx-autoapi                3.3.1
sphinx-rtd-theme              2.0.0
sphinxcontrib-applehelp       2.0.0
sphinxcontrib-devhelp         2.0.0
sphinxcontrib-htmlhelp        2.1.0
sphinxcontrib-jquery          4.1
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          2.0.0
sphinxcontrib-serializinghtml 2.0.0

my conf.py:

project = u"test"

extensions = [
         "myst_nb"
]

exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

html_theme = "sphinx_rtd_theme"
bsipocz commented 2 hours ago

I haven't tried a fix here, but for LaTeX heavy notebooks over at astroml-notebooks, padding the equations with empty lines solved these rendering issues for me.