quarto-dev / quarto-dev/quarto-cli
inconsistent behavior when rendering display math (`$$...$$`) in ipynb notebook when they are embedded (`$` get escaped)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Bug description
I noticed that the math object surrounded by double $$ get rendered differently if they belong to an embedded notebook (ipynb) rather than being directly rendered as documents.
The difference is triggered by whitespace around the $ or $$:
-
if there is no space between the fence and it's content, then it will always render correctly both as native document and as embedded document (e.g.
$x=4$,$$x = 5$$) -
if there is some space or a new line between the double
$$it's content, it get rendered differently:- get rendered correctly as "native" document
- get rendered incorrectly as an embed
(note: inline math with space, e.g. `$ x=4 $ will always get rendered incorrectly, therefore they are consistent at least)
Steps to reproduce
I have setup 3 files:
embedding_ipynb.qmd(main to be rendere)notebook_to_embed.ipynb(ipynb to embed)converted_notebook.qmd(qmd versione of the ipynb to check the difference)
main file to render
---
title: "embedding_ipynb"
format: html
keep-tex: true
---
## embedding_ipynb
{{< embed notebook_to_embed.ipynb >}}
{{< include converted_notebook.qmd >}}
notebook to embed
(I'm not sure how to properly reproduce a ipynb for bug purpose, but it's only markdown cells)
---
format: html
---
## notebook_to_embed.ipynb
inline equation $x=4$ and $ x=4.1 $
equation with ```$$..$$```:
$$x = 5$$
$$ x = 5.1 $$
equation in the style
| `$$`
| `...`
| `$$`
$$
x=6
$$
equation with `\begin{equation}...\end{equation}`:
\begin{equation}
x=7
\end{equation}
converted notebook in qmd for check
---
format: html
jupyter: python3
---
## converted_notebook.qmd
inline equation $x=4$ and $ x=4.1 $
equation with ```$$..$$```:
$$x = 5$$
$$ x = 5.1 $$
equation in the style:
| `$$`
| `...`
| `$$`
$$
x=6
$$
equation with `\begin{equation}...\end{equation}`:
\begin{equation}
x=7
\end{equation}
Expected behavior
I expect the math object to be rendered the same either if document is rendered as is, or if document is an embed of another document. The behavior should be consistent.
Actual behavior
the $ symbol from the embedded notebook get escaped if there is any space or new line between it and it's content, and thus do not render as math object, only when the ipynb is an embed. If the ipynb get rendered as its own document, it will render correctly.
Your environment
- vscode 1.85.2
- win 10 pro v. 10.0.19045
- quarto v. 1.4.549
- quarto vscode extension v1.110.1
Quarto check output
Quarto 1.4.549
[>] Checking versions of quarto binary dependencies...
Pandoc version 3.1.11: OK
Dart Sass version 1.69.5: OK
Deno version 1.37.2: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
Version: 1.4.549
Path: C:\Users\s.follador\AppData\Local\Programs\Quarto\bin
CodePage: 1252
[>] Checking tools....................OK
TinyTeX: v2023.12
Chromium: (not installed)
[>] Checking LaTeX....................OK
Using: TinyTex
Path: C:\Users\s.follador\AppData\Roaming\TinyTeX\bin\windows\
Version: 2023
[>] Checking basic markdown render....OK
[>] Checking Python 3 installation....OK
Version: 3.12.1
Path: C:/Users/s.follador/AppData/Local/Programs/Python/Python312/python.exe
Jupyter: 5.7.1
Kernels: python3
[>] Checking Jupyter engine render....OK
[>] Checking R installation...........(None)
Unable to locate an installed version of R.
Install R from https://cloud.r-project.org/
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with embedding_ipynb.qmd, notebook_to_embed.ipynb, and converted_notebook.qmd, then render the embedding and compare its math output with the converted notebook. Check the cases with spaces and newlines inside $$...$$; done means embedded notebook math renders consistently with the directly rendered or included document.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100