quarto-ext / shinylive

Quarto extension to embed Shinylive for Python applications
https://quarto-ext.github.io/shinylive/
MIT License
140 stars 7 forks source link

When multiple terminals are present in the same page only the last one is used as an output #27

Open perellonieto opened 8 months ago

perellonieto commented 8 months ago

I want to create a step by step guide on how to use Python and I have tried to create multiple block codes with an editor and a terminal. It seems that when there are multiple terminals in the same page only the last terminal is used as the output of all of them. However, the input (when clicking on run) seems to be associated with their respective code block.

The following is an example of the problem (with quarto version 1.3.450)

```{shinylive-python}
#| components: [editor, terminal]

print('This is the first code.')
#| components: [editor, terminal]

print('This is the second code.')
#| components: [editor, terminal]

print('This is the last code.')


An online example can be found at https://tailor-uob.github.io/mooc_trustworthy_ai/cha_sl/shinylive-not-working-terminals.html
and its source code at https://github.com/TAILOR-UoB/mooc_trustworthy_ai/blob/main/cha_sl/shinylive-not-working-terminals.qmd

Is there a way to fix this?
perellonieto commented 8 months ago

The issue #28 may be related to this one as I realized that the editor-terminal mode does not support the #| standalone: true argument.

```{shinylive-python}
#| standalone: true
#| components: [editor, terminal]

print('This is the first code.')
which fails with the following error ` '#| standalone: true' is not valid for editor-terminal and editor-cell code blocks.`.

However, adding a `viewer` and the `#| standalone: true` argument is able to generate the html page, but the problem of only the last terminal being used as an output persists.

````yaml
```{shinylive-python}
#| standalone: true
#| components: [editor, viewer, terminal]

print('This is the first code.')
#| standalone: true
#| components: [editor, viewer, terminal]

print('This is the second code.')
#| standalone: true
#| components: [editor, viewer, terminal]

print('This is the last code.')