Skip to content

Commit c0e98a8

Browse files
authored
Merge pull request #9692 from quarto-dev/bugfix/9691
lua - quarto.Tabset shouldn't require Attr
2 parents 4c3947b + e4e33fe commit c0e98a8

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

news/changelog-1.5.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ All changes included in 1.5:
161161
## Lua filters
162162

163163
- ([#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.
164+
- ([#9691](https://github.com/quarto-dev/quarto-cli/issues/9691)): Provide default Attr object to `quarto.Tabset` constructor.
164165

165166
## Other Fixes and Improvements
166167

src/resources/filters/customnodes/panel-tabset.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ _quarto.ast.add_handler({
124124
local custom_data = {
125125
__quarto_custom_node = node,
126126
level = params.level or 2,
127-
attr = params.attr or pandoc.Attr(),
127+
attr = params.attr or pandoc.Attr("", {"panel-tabset"}),
128128
}
129129

130130
local function make_tab_metaobject(custom_data, index)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
format: html
3+
filters:
4+
- topanel.lua
5+
_quarto:
6+
tests:
7+
html:
8+
ensureHtmlElements:
9+
- ["div.panel-tabset"]
10+
---
11+
12+
13+
::: {.to-panel}
14+
15+
```{r}
16+
#| echo: true
17+
18+
print("Hello, world")
19+
```
20+
21+
:::
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function Div(div)
2+
if not div.classes:includes("to-panel") then
3+
return
4+
end
5+
local code_block = nil
6+
local cell_output = nil
7+
quarto._quarto.ast.walk(div.content, {
8+
CodeBlock = function(code)
9+
if code.classes:includes("cell-code") then
10+
code_block = code
11+
end
12+
end,
13+
Div = function(div)
14+
if div.classes:includes("cell-output") then
15+
cell_output = div
16+
end
17+
end
18+
})
19+
20+
local rendered = quarto.Tab({ title = "Rendered", content = cell_output })
21+
local source = quarto.Tab({ title = "Source", code_block })
22+
local tabs = pandoc.List({ rendered, source })
23+
24+
return quarto.Tabset({
25+
level = 3,
26+
tabs = tabs
27+
})
28+
end

0 commit comments

Comments
 (0)