Skip to content

Commit

Permalink
Merge pull request #7636 from quarto-dev/layout-docx
Browse files Browse the repository at this point in the history
Fix regression on Docx Layout for non float elements
  • Loading branch information
cscheid authored Nov 20, 2023
2 parents 68afb79 + f0b9a50 commit 5673c6f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/resources/filters/layout/docx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,23 @@ end
_quarto.ast.add_renderer("PanelLayout", function(_)
return _quarto.format.isDocxOutput() or _quarto.format.isOdtOutput()
end, function(layout)
decorate_caption_with_crossref(layout.float)

local rendered_panel
local div = pandoc.Div({})

local layout_attr = pandoc.Attr(layout.identifier or "", layout.classes or {}, layout.attributes or {})
local float_attr = pandoc.Attr(layout.float.identifier or "", layout.float.classes or {}, layout.float.attributes or {})
div.attr = merge_attrs(float_attr, layout_attr)

local rows = layout.rows.content:map(function(div) return div.content end)
local rendered_panel = tableDocxPanel(div, rows, layout.float.caption_long)
local align = align_attribute(layout.float)
rendered_panel = docx_content_fixups(rendered_panel, align)
if layout.is_float_reftarget then
decorate_caption_with_crossref(layout.float)
local float_attr = pandoc.Attr(layout.float.identifier or "", layout.float.classes or {}, layout.float.attributes or {})
div.attr = merge_attrs(float_attr, layout_attr)

rendered_panel = tableDocxPanel(div, rows, layout.float.caption_long)
local align = align_attribute(layout.float)
rendered_panel = docx_content_fixups(rendered_panel, align)
else
div.attr = layout_attr
rendered_panel = tableDocxPanel(div, rows, nil)
end

local preamble = layout.preamble
if preamble == nil then
Expand Down
22 changes: 22 additions & 0 deletions tests/docs/smoke-all/2023/11/20/layout-ncol.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Layout ncol
format: docx
_quarto:
tests:
docx:
ensureDocxRegexMatches:
- ['<w:tbl>[\s\S]+?1\. Quarto[\s\S]+?</w:tbl>[\s\S]+?<w:tbl>[\s\S]+?3\. Passion[\s\S]+?</w:tbl>']
- []
---

::: {layout-ncol=2}

**1. Quarto** is a phenomenal software ecosystem for doing all steps of the scientific analysis and outreach all at once, possibly automated, definitely beautifully, and usually easily.

**2. Contributors:** Although many people contribute to the Quarto ecosystem, it seems to me that cderv, jjallaire, cscheid and dragonstyle are doing the heavy-lifting all day and night. We are very happy with your continuous improvements.

**3. Passion:** If I had become a millionaire I likely would have sponsored Quarto and related technologies even though I would not strictly needed it as an unemployed rich dude.

**4. Regrets:** Perhaps I should have just used the ipsum lorem generator at dragonstyle/lipsum instead of spending time flattering the authors.

:::

0 comments on commit 5673c6f

Please sign in to comment.