quarto-dev / quarto-cli

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

IPython.core.page.page() doesn't display output #10248

Open itamarst opened 2 months ago

itamarst commented 2 months ago

Bug description

IPython.core.page.page() is another way to display data in Jupyter/IPython. It doesn't seem to output anything in Quarto though.

Steps to reproduce

---
title: Reproducer
---

```{python}
from IPython.core.page import page
page("helloworld")

In a Jupyter notebook, this would display 'helloworld' as output, but in Quarto it displays nothing.


### Expected behavior

`helloworld` gets printed as output.

### Actual behavior

Nothing gets output.

### Your environment

Linux, Python 3.11.

### Quarto check output

Quarto 1.4.554 [✓] 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.554 Path: /opt/quarto/bin

[✓] Checking tools....................OK TinyTeX: (not installed) Chromium: (not installed)

[✓] Checking LaTeX....................OK Using: Installation From Path Path: /usr/bin Version: 2021

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK Version: 3.11.9 Path: /home/itamarst/devel/low-level-performance-book/venv/bin/python3 Jupyter: 5.7.0 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/
mcanouil commented 2 months ago

page is not equivalent to display as documented in IPython documentation.

See what is produced in the Jupyter cell:

pagedisplay
````json { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "helloworld" ] } ], "source": [ "from IPython.core.page import page\n", "page(\"helloworld\")" ] } ```` ````json { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'helloworld'" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from IPython.core.page import page\n", "from IPython.display import display\n", "display(\"helloworld\")" ] } ````
itamarst commented 2 months ago

It's not equivalent, sure, but nothing is displayed, which is wrong. (I have a personal workaround for my situation, so not urgent for me, but presumably other people will hit this too.)

mcanouil commented 2 months ago
  "name": "stdout",
  "output_type": "stream",

It does not seem right to me to display this kind of content. This is not data or text.

itamarst commented 2 months ago

As context, I encountered this as the output of line_profiler, which is definitely intended to be user visible. Whether line_profiler is using it correctly I don't know.

itamarst commented 2 months ago

https://ipython.readthedocs.io/en/stable/api/generated/IPython.core.page.html#IPython.core.page.page is the API docs: "Display content in a pager, piping through a pager after a certain length."