quarto-dev / quarto-dev/quarto-cli
Latex code embedding in jupyter programmatic HTML output not rendering in quarto
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Bug description
Jupyter renders latex code that appears in programmatic HTML output, but quarto is not doing this, leading to raw latex/MathJax appearing on rendered pages. By "programmatic", I mean anything involving _repr_html_() (or the equivalent IPython mime type). The below example uses IPython.display.HTML to accomplish this directly. The %%html cell magic also has this problem. I've tried to take a look at how MathJax is being invoked by default but I ran into minified code and got stuck.
Steps to reproduce
Here's a qmd that instantiates this problem, obviously it needs Jupyter to run. I've also given markdown for comparison (this behavior matches Jupyter and is essentially the behavior an html output should have; this also provides a partial workaround for now as markdown outputs do support html).
---
jupyter: python3
---
```{python}
from IPython.display import Latex, Markdown, HTML
display(Latex("$x_y$"))
display(Markdown("$x_y$"))
display(HTML("$x_y$"))
```
Expected behavior
Here's a screenshot of how this renders in standard Jupyter:
Actual behavior
Here's a screenshot of the rendered quarto output:
Your environment
- Jupyterlab: the screenshot above is from 3.1.18, but this is standard behavior for all versions of Jupyterlab. The quarto env actually has jupyter lab 4.0.6 in case that matters (which does mean that MathJax 3 is in play).
- tested on MacOS 11.7.9
- firefox (117.0.1) / chrome (116.0.5845.187)
Quarto check output
I wasn't able to figure out how to install a prerelease version in a way that isn't system-wide, sorry; but I did scan the changelog and didn't spot anything that would address this. I believe this is the correct pinned pandoc version for this version of quarto, but I also glanced at the pandoc changelog and didn't find anything. Happy to hear if I've missed it, though!
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.1.1: OK
Dart Sass version 1.58.3: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.3.450
Path: /Users/advil/miniforge3/envs/quarto2/bin
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.12.0 (Conda)
Path: /Users/advil/miniforge3/envs/quarto2/bin/python
Jupyter: 5.3.2
Kernels: python3, lambda-notebook-dev, lambda-notebook
(\) Checking Jupyter engine render....0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[✓] 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
Run the provided qmd reproduction with Jupyter and inspect how programmatic HTML from IPython.display.HTML and the %%html cell magic is emitted. Compare that output with standard Jupyter's handling of Latex and MathJax; the fix is complete when LaTeX in programmatic HTML renders as mathematics in Quarto HTML output without regressing the Markdown comparison.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter, python
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100