Skip to content

Commit

Permalink
Support code blocks for R Shiny apps
Browse files Browse the repository at this point in the history
  • Loading branch information
georgestagg committed Aug 23, 2023
1 parent 717b29c commit 5bc45a4
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions _extensions/quarto-ext/shinylive/shinylive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ end
return {
{
CodeBlock = function(el)
if el.attr and el.attr.classes:includes("{shinylive-python}") then
if el.attr and (
el.attr.classes:includes("{shinylive-python}")
or el.attr.classes:includes("{shinylive-r}")
) then
ensureShinyliveSetup()

-- Convert code block to JSON string in the same format as app.json.
Expand All @@ -90,8 +93,15 @@ return {
quarto.doc.attach_to_dependency("shinylive", dep)
end

el.attr.classes = pandoc.List()
el.attr.classes:insert("shinylive-python")
if el.attr.classes:includes("{shinylive-python}") then
el.attributes.engine = "python"
el.attr.classes = pandoc.List()
el.attr.classes:insert("shinylive-python")
elseif el.attr.classes:includes("{shinylive-r}") then
el.attributes.engine = "r"
el.attr.classes = pandoc.List()
el.attr.classes:insert("shinylive-r")
end
return el
end
end
Expand Down

0 comments on commit 5bc45a4

Please sign in to comment.