-
Notifications
You must be signed in to change notification settings - Fork 100
Express string output are quoted and wrapped in a code block #872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is the line where plain strings get wrapped into a py-shiny/shiny/express/_recall_context.py Line 46 in ceb6311
I was ambivalent about going this way vs rendering it as a plain string. I ended up going with I don't feel strongly committed to that direction, though. But if we change it, we will have to do a bit of education about why things look different in those different environments. In Express, the default would be plain text; you would have to wrap in a |
This behavior was also surprising to me too. Without the additional context of how things work in notebook contexts, it feels out of place that strings are wrapped in Relatedly, it'd be nice if Quarto supported Quarto Python Dashboard ExampleHere's an example with Quarto. Notice the cell option ---
title: "Penguin Bills"
format: dashboard
server: shiny
---
```{python}
import seaborn as sns
penguins = sns.load_dataset("penguins")
```
## {.sidebar}
```{python}
from shiny import render, ui
ui.input_select("x", "Variable:",
choices=["bill_length_mm", "bill_depth_mm"])
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
ui.input_checkbox("rug", "Show rug marks", value = False)
```
## Column
```{python}
#| output: asis
print(f"There are {len(penguins)} penguins in this dataset.")
```
```{python}
@render.plot
def displot():
sns.displot(
data=penguins, hue="species", multiple="stack",
x=input.x(), rug=input.rug(), kind=input.dist())
``` A middle ground might be to treat top-level and child strings differently. from shiny.express import layout
"Hello"
with layout.div():
"express" If the outer from shiny.express import layout
from shiny import ui
"Hello"
with layout.div():
with layout.span():
"express"
with layout.div():
ui.span("express") |
After a conversation with @cpsievert and @jcheng5, we settled on this:
Other notes:
A summary of the reasoning: Generally speaking, there are two kinds of text you'd want to put in a document:
In Jupyter and Quarto, there is an easy way to add both types of text:
In the current form of Shiny Express, it works like this:
In the proposed form of Shiny Express:
|
I find this behavior surprising (both the quoting and wrapping of strings into a code block):
I would have expected a result closer to:
Especially considering it's not terribly hard to opt-into code blocks (and I think we've been considering adding a more official one)?
But maybe there's additional rationale for this as a default that I'm not aware of?
The text was updated successfully, but these errors were encountered: