Skip to content

Commit

Permalink
post(new): shinylive & quartolive
Browse files Browse the repository at this point in the history
  • Loading branch information
YONGHUNI committed Oct 18, 2024
1 parent 6aeab66 commit 093fc4d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
6 changes: 3 additions & 3 deletions _extensions/quarto-ext/shinylive/_extension.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: shinylive
title: Embedded Shinylive applications
author: Winston Chang
version: 0.1.0
quarto-required: ">=1.2.198"
version: 0.2.0
quarto-required: ">= 1.2.198"
contributes:
filters:
- shinylive.lua
- shinylive.lua
23 changes: 20 additions & 3 deletions _extensions/quarto-ext/shinylive/shinylive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ end
-- @param input: string to pipe into to r-shinylive
function callRShinylive(args, input)
args = { "-e",
"pkgload::load_all('../../', quiet = TRUE); shinylive::quarto_ext()",
"shinylive:::quarto_ext()",
table.unpack(args) }

-- Try calling `pandoc.pipe('Rscript', ...)` and if it fails, print a message
Expand Down Expand Up @@ -393,6 +393,16 @@ function getShinyliveBaseDeps(language)
return deps
end

-- Legacy quarto cli location
quarto_cli_path = "quarto"
if quarto.config ~= nil and quarto.config.cli_path ~= nil then
-- * 2024/05/03 - Christophe:
-- `quarto run` needs to be called using the same quarto CLI that called the extension.
-- This is done by using `quarto.config.cli_path()` from Quarto 1.5 Lua API.
-- https://github.com/quarto-dev/quarto-cli/pull/9576
quarto_cli_path = quarto.config.cli_path()
end

return {
{
CodeBlock = function(el)
Expand All @@ -415,7 +425,7 @@ return {

-- Convert code block to JSON string in the same format as app.json.
local parsedCodeblockJson = pandoc.pipe(
"quarto",
quarto_cli_path,
{ "run", codeblockScript, language },
el.text
)
Expand Down Expand Up @@ -448,7 +458,14 @@ return {
el.attr.classes = pandoc.List()
el.attr.classes:insert("shinylive-r")
end

el.text =
"#| '!! shinylive warning !!': |\n"..
"#| shinylive does not work in self-contained HTML documents.\n" ..
"#| Please set `embed-resources: false` in your metadata.\n" ..
el.text

return el
end
}
}
}

0 comments on commit 093fc4d

Please sign in to comment.