quarto-dev / quarto-cli

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

Untrusted jupyter notebook when using JS for hugo format #850

Closed linogaliana closed 2 years ago

linogaliana commented 2 years ago

Hi, once again thanks a lot for quarto which is an excellent tool.

I tried to use folium with quarto to build a Python course website. The output format is hugo. Instead of the map the python block should have produced, this message appeared:

Make this Notebook Trusted to load map: File -> Trust Notebook<iframe srcdoc="<!DOCTYPE html>

This is a typical Jupyter security message as stated in the doc.

I put a minimal reproducible exemple at the end of the issue based on folium documentation to show how to recreate the problem.

Is there some way, behind the stage, to make jupyter trust all sessions launched by quarto ?

What is surprising is that this behavior does not happen when using html output

Reprex

Let's create a file example.qmd :

---
title: "Plotly example"
html: default
---

```{python}
import folium
m = folium.Map(location=[45.5236, -122.6750])
```

```{python}
m
```

When using quarto render example.qmd --to html, no problem at all. Map is visible.

When using quarto render example.qmd --to hugo, instead of the map we have the Make this Notebook Trusted to load map (and lot's of misformed content I don't understand)

I also tried to replace the printing of the map using m by

```{python}
#| include: false
#| eval: false
map = m._repr_html_()
```

```{python}
#| echo: false
#| output: asis
#| eval: false
print(map)
```

(which was my R Markdown way of doing) but the result is the same

Update: it works as expected for ipynb output. Problem is really for hugo format

jjallaire commented 2 years ago

This works fine for in Hugo so long as I've followed the instructions to enable HTML output in Hugo (see https://quarto.org/docs/output-formats/hugo.html#site-config)

Here is my config.toml:

baseURL = 'http://example.org/'
languageCode = 'en-us'
title = 'My New Hugo Site'
theme = "ananke"

ignoreFiles = [ "\\.qmd$", "\\.ipynb$" ]

[markup.goldmark.renderer]
unsafe= true
linogaliana commented 2 years ago

I tested in local and indeed I did not face that problem. I am going to further inquire on this subjevt (but my guess is that it is related to the fact I was building the qmd->md from github actions but used a different machine to run hugo serve)

linogaliana commented 2 years ago

found that the problem was my academic theme that was not digesting well raw html. Solved the issue that is not quarto related