Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amsmath parsing error of equation with multiple bmatrix envs #120

Closed
tovrstra opened this issue Sep 8, 2024 · 1 comment
Closed

amsmath parsing error of equation with multiple bmatrix envs #120

tovrstra opened this issue Sep 8, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@tovrstra
Copy link

tovrstra commented Sep 8, 2024

Describe the bug

context

The following is not parsed correctly (file bug.md):

---
myst:
  enable_extensions: ["amsmath"]
---

> \begin{equation} \mathbf{Ax}=
\begin{bmatrix}
-0&1&0\\
-0&0&1\\
1&-1&1
\end{bmatrix}\begin{bmatrix}
x_1\\ x_2\\ x_3
\end{bmatrix}
\cong
\begin{bmatrix}
-3.2\\-2.1\\1.2
\end{bmatrix}=\mathbf{b}
\end{equation}

This comes from a larger notebook. The simplest way to see the problem is to run

myst-docutils-demo bug.md --math-output=LaTeX

expectation

<blockquote>
<pre class="math amsmath">
\begin{equation} \mathbf{Ax}=
\begin{bmatrix}
-0&amp;1&amp;0\\
-0&amp;0&amp;1\\
1&amp;-1&amp;1
\end{bmatrix}\begin{bmatrix}
x_1\\ x_2\\ x_3
\end{bmatrix}
\cong
\begin{bmatrix}
-3.2\\-2.1\\1.2
\end{bmatrix}=\mathbf{b}
\end{equation}
</pre>
</blockquote>

bug

I get the following output:

<blockquote>
<p>\begin{equation} \mathbf{Ax}=</p>
</blockquote>
<pre class="math amsmath">
\begin{bmatrix}
-0&amp;1&amp;0\\
-0&amp;0&amp;1\\
1&amp;-1&amp;1
\end{bmatrix}\begin{bmatrix}
x_1\\ x_2\\ x_3
\end{bmatrix}
</pre>
<p>\cong
\begin{bmatrix}
-3.2\-2.1\1.2
\end{bmatrix}=\mathbf{b}
\end{equation}</p>

problem

This is a problem for people converting notebooks written in Jupyter or VSCode because these environments render this example correctly.

Jupyter:

jupyterlab

VSCode:

vscode

Reproduce the bug

See input and steps above.

List your environment

I installed the development branch (3f7fcc6) with:

pip install git+https://github.com/executablebooks/mdit-py-plugins

Output of pip list:

Package                           Version
--------------------------------- ------------------
alabaster                         0.7.14
anyio                             4.3.0
appdirs                           1.4.4
argon2-cffi                       23.1.0
argon2-cffi-bindings              21.2.0
arrow                             1.3.0
asn1crypto                        1.5.1
astropy                           6.1.3
astropy-iers-data                 0.2024.9.2.0.33.23
asttokens                         2.4.1
async-lru                         2.0.4
atomicwrites                      1.4.1
attrs                             23.1.0
babel                             2.16.0
backcall                          0.2.0
backports.entry-points-selectable 1.2.0
backports.functools-lru-cache     1.6.6
beautifulsoup4                    4.12.2
beniget                           0.4.1
binaryornot                       0.4.4
bitarray                          2.8.2
bitstring                         4.1.2
bleach                            6.1.0
Bottleneck                        1.3.7
build                             1.2.2
CacheControl                      0.13.1
cachy                             0.3.0
cattrs                            24.1.0
certifi                           2024.8.30
cffi                              1.16.0
cfgv                              3.4.0
chardet                           5.2.0
charset-normalizer                3.3.2
cleo                              2.0.1
click                             8.1.7
cloudpickle                       3.0.0
colorama                          0.4.6
comm                              0.2.2
commonmark                        0.9.1
contourpy                         1.2.0
cookiecutter                      2.6.0
crashtest                         0.4.1
cryptography                      41.0.5
cycler                            0.12.1
Cython                            3.0.4
deap                              1.4.1
debugpy                           1.8.1
decorator                         5.1.1
defusedxml                        0.7.1
deprecation                       2.1.0
distlib                           0.3.7
distro                            1.8.0
docopt                            0.6.2
docstring-to-markdown             0.15
docutils                          0.21.2
doit                              0.36.0
dulwich                           0.21.6
ecdsa                             0.18.0
editables                         0.5
exceptiongroup                    1.1.3
execnet                           2.0.2
executing                         2.0.1
fastjsonschema                    2.19.1
filelock                          3.13.0
flit_core                         3.9.0
fonttools                         4.47.0
fqdn                              1.5.1
fsspec                            2023.10.0
furo                              2024.8.6
future                            0.18.3
gast                              0.5.4
gitdb                             4.0.11
GitPython                         3.1.43
glob2                             0.7
gmpy2                             2.1.5
greenlet                          3.0.3
h11                               0.14.0
html5lib                          1.1
httpcore                          1.0.5
httpx                             0.27.0
hypothesis                        6.90.0
identify                          2.6.0
idna                              3.8
imagesize                         1.4.1
importlib-metadata                6.8.0
importlib-resources               6.1.0
iniconfig                         2.0.0
intersphinx_registry              0.2408.13
intervaltree                      3.1.0
intreehooks                       1.0
ipaddress                         1.0.23
ipykernel                         6.29.4
ipympl                            0.9.4
ipytest                           0.14.2
ipython                           8.17.2
ipython-genutils                  0.2.0
ipywidgets                        8.1.2
isoduration                       20.11.0
jaraco.classes                    3.3.0
jax                               0.4.31
jaxlib                            0.4.31
jedi                              0.19.1
jeepney                           0.8.0
Jinja2                            3.1.4
joblib                            1.3.2
json5                             0.9.25
jsonpointer                       3.0.0
jsonschema                        4.18.0
jsonschema-specifications         2023.12.1
jupyter-cache                     1.0.0
jupyter_client                    8.6.1
jupyter_core                      5.7.2
jupyter-events                    0.10.0
jupyter-lsp                       2.2.5
jupyter_packaging                 0.12.3
jupyter-resource-usage            1.1.0
jupyter_server                    2.14.0
jupyter-server-mathjax            0.2.6
jupyter_server_terminals          0.5.3
jupyterlab                        4.2.0
jupyterlab_code_formatter         3.0.2
jupyterlab_git                    0.50.1
jupyterlab_latex                  4.1.3
jupyterlab-lsp                    5.1.0
jupyterlab_pygments               0.3.0
jupyterlab_server                 2.27.1
jupyterlab_widgets                3.0.10
jupytext                          1.16.4
keyring                           24.2.0
keyrings.alt                      5.0.0
kiwisolver                        1.4.4
latexcodec                        3.0.0
liac-arff                         2.5.0
lockfile                          0.12.2
lsprotocol                        2023.0.1
lxml                              4.9.3
markdown-it-py                    3.0.0
MarkupSafe                        2.1.5
matplotlib                        3.8.2
matplotlib-inline                 0.1.6
mdit-py-plugins                   0.4.1
mdurl                             0.1.2
mistune                           3.0.2
ml-dtypes                         0.4.0
mock                              5.1.0
more-itertools                    10.1.0
mpmath                            1.3.0
msgpack                           1.0.7
myst-nb                           1.1.1
myst-parser                       4.0.0
nbclient                          0.10.0
nbconvert                         7.16.4
nbdime                            4.0.2
nbformat                          5.10.4
nest-asyncio                      1.6.0
netaddr                           0.9.0
netifaces                         0.11.0
nodeenv                           1.9.1
notebook_shim                     0.2.4
numexpr                           2.8.7
numpy                             1.26.2
numpydoc                          1.8.0
opt-einsum                        3.3.0
overrides                         7.7.0
packaging                         24.1
pandas                            2.1.3
pandocfilters                     1.5.1
parso                             0.8.3
pastel                            0.2.1
pathlib2                          2.3.7.post1
pathspec                          0.11.2
pbr                               5.11.1
pexpect                           4.8.0
pickleshare                       0.7.5
pillow                            10.2.0
pip                               23.3.2
pip-tools                         7.4.1
pkginfo                           1.9.6
platformdirs                      3.11.0
pluggy                            1.3.0
ply                               3.11
pooch                             1.8.0
pre-commit                        3.8.0
prometheus_client                 0.20.0
prompt-toolkit                    3.0.41
psutil                            5.9.6
ptyprocess                        0.7.0
pure-eval                         0.2.2
py                                1.11.0
py-expression-eval                0.3.14
pyasn1                            0.5.0
pybind11                          2.11.1
pybtex                            0.24.0
pybtex-docutils                   1.0.3
pycparser                         2.21
pycryptodome                      3.19.0
pydevtool                         0.3.0
pyerfa                            2.0.1.4
Pygments                          2.18.0
pylev                             1.4.0
PyNaCl                            1.5.0
pyparsing                         3.1.1
pyproject_hooks                   1.1.0
pyrsistent                        0.20.0
pytest                            7.4.3
pytest-xdist                      3.3.1
python-dateutil                   2.8.2
python-json-logger                2.0.7
python-lsp-jsonrpc                1.1.2
python-lsp-ruff                   2.2.2
python-lsp-server                 1.12.0
python-slugify                    8.0.4
pythran                           0.14.0
pytoml                            0.1.21
pytz                              2023.3.post1
PyYAML                            6.0.1
pyzmq                             25.1.2
rapidfuzz                         2.15.2
referencing                       0.35.1
regex                             2023.10.3
requests                          2.32.3
requests-toolbelt                 1.0.0
rfc3339-validator                 0.1.4
rfc3986-validator                 0.1.1
rich                              13.6.0
rich-click                        1.7.0
rpds-py                           0.18.1
ruff                              0.6.3
scandir                           1.10.0
schemdraw                         0.19
scipy                             1.11.4
SecretStorage                     3.3.3
semantic-version                  2.10.0
Send2Trash                        1.8.3
setuptools                        74.1.2
setuptools-scm                    8.0.4
shellingham                       1.5.4
simplegeneric                     0.8.1
simplejson                        3.19.2
six                               1.16.0
smmap                             5.0.1
sniffio                           1.3.1
snowballstemmer                   2.2.0
sortedcontainers                  2.4.0
soupsieve                         2.5
Sphinx                            8.0.2
sphinx-autobuild                  2024.9.3
sphinx-basic-ng                   1.0.0b2
sphinx-bootstrap-theme            0.8.1
sphinx-codeautolink               0.15.2
sphinx-copybutton                 0.5.2
sphinxcontrib-applehelp           2.0.0
sphinxcontrib-bibtex              2.6.2
sphinxcontrib-devhelp             2.0.0
sphinxcontrib-htmlhelp            2.1.0
sphinxcontrib-jsmath              1.0.1
sphinxcontrib-qthelp              2.0.0
sphinxcontrib-serializinghtml     2.0.0
sphinxcontrib-svg2pdfconverter    1.2.2
sphinxcontrib-websupport          2.0.0
SQLAlchemy                        2.0.34
stack-data                        0.6.3
starlette                         0.38.4
sympy                             1.12
tabulate                          0.9.0
terminado                         0.18.1
text-unidecode                    1.3
threadpoolctl                     3.2.0
tinycss2                          1.3.0
toml                              0.10.2
tomli                             2.0.1
tomli_w                           1.0.0
tomlkit                           0.12.1
tornado                           6.4
traitlets                         5.13.0
types-python-dateutil             2.9.0.20240906
typing_extensions                 4.8.0
tzdata                            2023.3
ujson                             5.8.0
uri-template                      1.3.0
urllib3                           2.2.2
uvicorn                           0.30.6
versioneer                        0.29
virtualenv                        20.24.6
watchfiles                        0.24.0
wcwidth                           0.2.8
webcolors                         24.8.0
webencodings                      0.5.1
websocket-client                  1.8.0
websockets                        13.0.1
wheel                             0.41.2
widgetsnbextension                4.0.10
xlrd                              2.0.1
zipfile36                         0.1.3
zipp                              3.17.0
@tovrstra tovrstra added the bug Something isn't working label Sep 8, 2024
@chrisjsewell
Copy link
Member

Heya, this is not a bug; it is functioning exactly as it is intended to function (since #119)

In particular, here it adheres to https://spec.commonmark.org/0.31.2/#example-234

Laziness only applies to lines that would have been continuations of paragraphs

In this the case, the \begin{bmatrix} interrupts the laziness

Put simply; you should NOT rely on laziness, EVERY line of a blockquote should be prefixed with > to ensure the correct output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants