Skip to content

Commit 68557de

Browse files
authored
Merge pull request #12776 from quarto-dev/bugfix/12775
`beamer`: convert `layout` to columns
2 parents 1b86eb2 + 4ef2c65 commit 68557de

File tree

5 files changed

+57
-7
lines changed

5 files changed

+57
-7
lines changed

news/changelog-1.8.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ All changes included in 1.8:
3030
- ([#12554](https://github.com/quarto-dev/quarto-cli/pull/12554)): CSS properties `font-weight` and `font-style` are translated to Typst `text` properties.
3131
- ([#12739](https://github.com/quarto-dev/quarto-cli/pull/12739)): Remove unused variable `heading-background-color` and `heading-decoration` from Typst's templates. They are leftover from previous change, and not part of Brand.yml schema for typography of headings.
3232

33+
### `beamer`
34+
35+
- ([#12775](https://github.com/quarto-dev/quarto-cli/issues/12775)): Convert Quarto-native layouts (divs with `layout` syntax) to Beamer columns, equivalent to using the Pandoc-native syntax of div with `columns` and `column` classes.
36+
3337
## Projects
3438

3539
### `website`

src/resources/filters/common/layout.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@ function layout_align_attribute(el_with_attr, default)
1111
return validatedAlign(el_with_attr.attributes[kLayoutAlign], default)
1212
end
1313

14-
-- now unused. Remove?
15-
-- luacov: disable
1614
function layout_valign_attribute(el_with_attr, default)
1715
return validatedVAlign(el_with_attr.attributes[kLayoutVAlign] or default)
1816
end
19-
-- luacov: enable
2017

2118
function attr_has_layout_attributes(attr)
2219
local attribs = tkeys(attr.attributes)

src/resources/filters/common/validate.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
-- validate.lua
22
-- Copyright (C) 2020-2022 Posit Software, PBC
33

4-
kAlignments = pandoc.List({ "center", "left", "right" })
5-
kVAlignments = pandoc.List({"top", "center", "bottom"})
64

75
function validatedAlign(align, default)
6+
local kAlignments = pandoc.List({ "center", "left", "right" })
87
return validateInList(align, kAlignments, "alignment", default)
98
end
109

1110
function validatedVAlign(vAlign)
11+
local kVAlignments = pandoc.List({"top", "top-baseline", "center", "bottom"})
1212
return validateInList(vAlign, kVAlignments, "vertical alignment", "top")
1313
end
1414

src/resources/filters/layout/latex.lua

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ kSideCaptionEnv = 'sidecaption'
44

55
_quarto.ast.add_renderer("PanelLayout", function(_)
66
return _quarto.format.isLatexOutput()
7-
end, function(layout)
7+
end, function (layout)
88
local rendered_panel = latexPanel(layout)
99
local preamble = layout.preamble
1010
if preamble == nil then
@@ -18,9 +18,41 @@ end, function(layout)
1818
return result
1919
end)
2020

21+
_quarto.ast.add_renderer("PanelLayout", function(_)
22+
return _quarto.format.isBeamerOutput()
23+
end, function(panel)
24+
local result = pandoc.Blocks({})
25+
if panel.preamble then
26+
panel_insert_preamble(result, panel.preamble)
27+
end
28+
29+
for i, row in ipairs(panel.layout) do
30+
local beamer_cols = pandoc.Div({}, pandoc.Attr("", { "columns" }))
31+
for j, cell in ipairs(row) do
32+
local attrs = {}
33+
local align = nil
34+
-- NB: column "align" in beamer is "valign" in our layouts
35+
if cell.attributes["valign"] then
36+
align = cell.attributes["valign"]
37+
end
38+
if cell.attributes["width"] then
39+
attrs.width = cell.attributes["width"]
40+
end
41+
if align then
42+
attrs.align = align
43+
end
44+
local beamer_col = pandoc.Div({}, pandoc.Attr(cell.identifier, { "column" }, attrs))
45+
beamer_col.content:extend(cell.content)
46+
beamer_cols.content:insert(beamer_col)
47+
end
48+
result:insert(beamer_cols)
49+
end
50+
51+
return result
52+
end)
53+
2154
-- function latexPanel(divEl, layout, caption)
2255
function latexPanel(layout)
23-
2456
-- begin container
2557
local env, pos = latexPanelEnv(layout)
2658
local panel_node, panel = quarto.LatexEnvironment({
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: "title"
3+
date: last-modified
4+
format: beamer
5+
---
6+
7+
## slide
8+
9+
::::::{layout="[48, 48]"}
10+
:::{#first-column valign="bottom"}
11+
hallo
12+
:::
13+
:::{#second-column valign="top-baseline"}
14+
### a block title
15+
du
16+
:::
17+
::::::

0 commit comments

Comments
 (0)