reflex
reflex copied to clipboard
Fix escaping quotes in dict values
Currently escaping quotes in string props is not working always.
The following prop doesn't compile correctly:
pc.text(
"hello",
font_family='"Fira Code", Menlo, Consolas, monospace'
)
Can I work on this?
import reflex as rx
class State(rx.State):
pass
def index() -> rx.Component:
return rx.fragment(
rx.vstack(
rx.text(
"broken",
font_family='"Fira Code", Menlo, Consolas, monospace'
),
rx.text(
"working",
font_family="'Fira Code', Menlo, Consolas, monospace"
),
padding_top="10%",
),
)
app = rx.App()
app.add_page(index)
app.compile()
reflex-0.2.4 generates code like
<Text sx={{"fontFamily": ""Fira Code", Menlo, Consolas, monospace"}}>
{`broken`}
</Text>
<Text sx={{"fontFamily": "'Fira Code', Menlo, Consolas, monospace"}}>
{`working`}
</Text>
The quotes around "Fira Code" are themselves wrapped in double quotes, and not escaped, which is obviously wrong.
With #1609 merging in for reflex-0.2.5, this case is no longer an issue:
<Text sx={{"fontFamily": "\"Fira Code\", Menlo, Consolas, monospace"}}>
{`broken`}
</Text>
<Text sx={{"fontFamily": "'Fira Code', Menlo, Consolas, monospace"}}>
{`working`}
</Text>
Note the quote escapes in the JSX now π