quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.97k stars 328 forks source link

Conflict between katex, pandas and embed-resources #10113

Open maurosilber opened 5 months ago

maurosilber commented 5 months ago

The following example does not render the math, leaving a literal \alpha in the slides:

---
format: revealjs
embed-resources: true
html-math-method: katex
minimal: true
---

$\alpha$

```{python}
import pandas as pd
pd.DataFrame([1])


It produces a `TypeError: undefined is not an object (evaluating 'window.katex.render')` in the browser's console.

It's triggered by the combination of the three settings:
- `embed-resources: true`
- `html-math-method: katex`
- displaying a `pandas.DataFrame`

Removing any of these solves the issue.
maurosilber commented 5 months ago

Adding html-table-processing: none does not solve the issue.

It works when converting to markdown:

```{python}
import pandas as pd
from IPython.display import Markdown

Markdown(pd.DataFrame([1]).to_markdown())
cderv commented 5 months ago

Just removed unneeded content for the header. It is reproducing with html, specifically when embedding resources

---
format: html
embed-resources: true
html-math-method: katex
---

$\alpha$

```{python}
import pandas as pd
pd.DataFrame([1])

It is probably an issue with the evasion of self-contained for Math. See our doc about `self-contained-math: false` being the default (https://quarto.org/docs/output-formats/html-publishing.html#standalone-html)

Using `self-contained-math: true` works 
````markdown
---
format: html
embed-resources: true
html-math-method: katex
self-contained-math: true
---

$\alpha$

```{python}
import pandas as pd
pd.DataFrame([1])


So probably our patching has some issue in this specific case. 

For reference this where the JS script failing was added (48dff0551669bb55d07def3309ad5a678732ad1c)
cderv commented 5 months ago

BTW probably an issue with JQuery which is brought by Pandas. When using the Markdown formatting, Pandas does not bring JQuery. So it could also be a conflict between the JQuery version brought and Katex version or our handling for self contained loading.