|
4 | 4 | _quarto.ast.add_renderer("PanelLayout", function(_)
|
5 | 5 | return _quarto.format.isHugoMarkdownOutput()
|
6 | 6 | end, function(layout)
|
| 7 | + local function make_panel_content() |
| 8 | + local panel_content = pandoc.Blocks({}) |
| 9 | + -- layout |
| 10 | + for i, row in ipairs(layout.layout) do |
| 11 | + |
| 12 | + local aligns = row:map(function(cell) |
| 13 | + -- get the align |
| 14 | + local align = cell.attributes[kLayoutAlign] |
| 15 | + return layoutTableAlign(align) |
| 16 | + end) |
| 17 | + local widths = row:map(function(cell) |
| 18 | + -- propagage percents if they are provided |
| 19 | + local layoutPercent = horizontalLayoutPercent(cell) |
| 20 | + if layoutPercent then |
| 21 | + return layoutPercent / 100 |
| 22 | + else |
| 23 | + return 0 |
| 24 | + end |
| 25 | + end) |
| 26 | + |
| 27 | + local cells = pandoc.List() |
| 28 | + for _, cell in ipairs(row) do |
| 29 | + cells:insert(cell) |
| 30 | + end |
| 31 | + |
| 32 | + -- make the table |
| 33 | + local panelTable = pandoc.SimpleTable( |
| 34 | + pandoc.List(), -- caption |
| 35 | + aligns, |
| 36 | + widths, |
| 37 | + pandoc.List(), -- headers |
| 38 | + pandoc.List { cells } |
| 39 | + ) |
| 40 | + |
| 41 | + -- add it to the panel |
| 42 | + panel_content:insert(pandoc.utils.from_simple_table(panelTable)) |
| 43 | + end |
| 44 | + return panel_content |
| 45 | + end |
| 46 | + |
7 | 47 | if layout.float == nil then
|
8 |
| - fail_and_ask_for_bug_report("Can't render layouts without floats") |
9 |
| - return pandoc.Div({}) |
| 48 | + -- if there is no float, then we just return the content and preamble |
| 49 | + local result = pandoc.Div(layout.preamble or {}) |
| 50 | + result.content:extend(make_panel_content()) |
| 51 | + return result |
10 | 52 | end
|
11 | 53 | decorate_caption_with_crossref(layout.float)
|
12 | 54 |
|
13 | 55 | -- empty options by default
|
14 | 56 | if not options then
|
15 | 57 | options = {}
|
16 | 58 | end
|
17 |
| - -- outer panel to contain css and figure panel |
18 |
| - local attr = pandoc.Attr(layout.identifier or "", layout.classes or {}, layout.attributes or {}) |
19 |
| - local panel_content = pandoc.Blocks({}) |
20 |
| - -- layout |
21 |
| - for i, row in ipairs(layout.layout) do |
22 |
| - |
23 |
| - local aligns = row:map(function(cell) |
24 |
| - -- get the align |
25 |
| - local align = cell.attributes[kLayoutAlign] |
26 |
| - return layoutTableAlign(align) |
27 |
| - end) |
28 |
| - local widths = row:map(function(cell) |
29 |
| - -- propagage percents if they are provided |
30 |
| - local layoutPercent = horizontalLayoutPercent(cell) |
31 |
| - if layoutPercent then |
32 |
| - return layoutPercent / 100 |
33 |
| - else |
34 |
| - return 0 |
35 |
| - end |
36 |
| - end) |
37 |
| - |
38 |
| - local cells = pandoc.List() |
39 |
| - for _, cell in ipairs(row) do |
40 |
| - cells:insert(cell) |
41 |
| - end |
42 |
| - |
43 |
| - -- make the table |
44 |
| - local panelTable = pandoc.SimpleTable( |
45 |
| - pandoc.List(), -- caption |
46 |
| - aligns, |
47 |
| - widths, |
48 |
| - pandoc.List(), -- headers |
49 |
| - { cells } |
50 |
| - ) |
51 |
| - |
52 |
| - -- add it to the panel |
53 |
| - panel_content:insert(pandoc.utils.from_simple_table(panelTable)) |
54 |
| - end |
| 59 | + local panel_content = make_panel_content() |
55 | 60 |
|
| 61 | + -- outer panel to contain css and figure panel |
56 | 62 | local result = pandoc.Div({})
|
57 | 63 | -- the format for the rawblock is html and not markdown_strict
|
58 | 64 | -- because this might end up inside a table, and Pandoc
|
|
0 commit comments