Skip to content
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

lua - quarto.Tabset shouldn't require Attr #9692

Merged
merged 3 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ All changes included in 1.5:
## Lua filters

- ([#9572](https://github.com/quarto-dev/quarto-cli/issues/9572)): Add `quarto.config.cli_path()` in Quarto LUA to return the path to the Quarto CLI executable of the installation running the Lua script in quarto context.
- ([#9691](https://github.com/quarto-dev/quarto-cli/issues/9691)): Provide default Attr object to `quarto.Tabset` constructor.

## Other Fixes and Improvements

Expand Down
2 changes: 1 addition & 1 deletion src/resources/filters/customnodes/panel-tabset.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ _quarto.ast.add_handler({
local custom_data = {
__quarto_custom_node = node,
level = params.level or 2,
attr = params.attr or pandoc.Attr(),
attr = params.attr or pandoc.Attr("", {"panel-tabset"}),
}

local function make_tab_metaobject(custom_data, index)
Expand Down
21 changes: 21 additions & 0 deletions tests/docs/smoke-all/2024/05/15/9691.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
format: html
filters:
- topanel.lua
_quarto:
tests:
html:
ensureHtmlElements:
- ["div.panel-tabset"]
---


::: {.to-panel}

```{r}
#| echo: true

print("Hello, world")
```

:::
28 changes: 28 additions & 0 deletions tests/docs/smoke-all/2024/05/15/topanel.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function Div(div)
if not div.classes:includes("to-panel") then
return
end
local code_block = nil
local cell_output = nil
quarto._quarto.ast.walk(div.content, {
CodeBlock = function(code)
if code.classes:includes("cell-code") then
code_block = code
end
end,
Div = function(div)
if div.classes:includes("cell-output") then
cell_output = div
end
end
})

local rendered = quarto.Tab({ title = "Rendered", content = cell_output })
local source = quarto.Tab({ title = "Source", code_block })
local tabs = pandoc.List({ rendered, source })

return quarto.Tabset({
level = 3,
tabs = tabs
})
end
Loading