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

A terminal component blocks the execution of all subsequent viewers #28

Open perellonieto opened 8 months ago

perellonieto commented 8 months ago

If a code block includes the component terminal all the subsequent code blocks that have a viewer are not rendered (with quarto version 1.3.450).

The following is a code example that does not allow the 2 last code blocks to render.

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

print('First code will prevent the rest of the code blocks from showing their rendered output')
#| standalone: true
#| components: [editor, viewer]
from shiny import App, ui

app_ui = ui.page_fluid("The text in the second code block is not shown.")

app = App(app_ui, None)
#| standalone: true
#| components: [editor, viewer]
from shiny import App, ui

app_ui = ui.page_fluid("The text in the third code block is not shown.")

app = App(app_ui, None)


A live example can be seen at https://tailor-uob.github.io/mooc_trustworthy_ai/cha_sl/shinylive-not-working.html
and the source code of the example at https://github.com/TAILOR-UoB/mooc_trustworthy_ai/blob/main/cha_sl/shinylive-not-working.qmd
wch commented 8 months ago

Thanks for providing the very clear example. If there is a viewer block before the terminal, does it run?

perellonieto commented 8 months ago

I changed the title as I meant a terminal blocks the subsequent viewers.

If I only add a viewer to the previous code

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

print('First code will prevent the rest of the code blocks from showing their rendered output')

it raises an error about the argument `#| standalone: true` being necessary. 

If I add the `#| standalone: true` option 

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

print('First code will prevent the rest of the code blocks from showing their rendered output')

I raises the error `'#| standalone: true' is not valid for editor-terminal and editor-cell code blocks.` which may be related to this issue.

And if I add both the  `#| standalone: true` option and the `viewer`

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

print('First code will prevent the rest of the code blocks from showing their rendered output')

 the page is rendered as expected. Then as indicated above the original problem is that the current implementation of the shinylive extension does not support a standalone terminal.

If this is correct, are there any plans to work on the `standalone` argument?