Skip to content

Commit

Permalink
fix more pandoc nils
Browse files Browse the repository at this point in the history
more mechanical fixes for lightbox and docx
where pandoc is now correctly populating nils
fixes #9444
fixes #9477
  • Loading branch information
gordonwoodhull committed Apr 25, 2024
1 parent 366a528 commit e1b9356
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/resources/filters/layout/docx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function docxDivCaption(captionEl, align)
local caption = pandoc.Para({
pandoc.RawInline("openxml", docxParaStyles(align))
})
tappend(caption.content, captionEl.content)
tappend(caption.content, captionEl and captionEl.content or pandoc.Inlines({}))
return caption
end

Expand Down
7 changes: 6 additions & 1 deletion src/resources/filters/layout/lightbox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ function lightbox()
subFloatEl = _quarto.ast.walk(subFloatEl, {
traverse = 'topdown',
Image = function(imgEl)
local caption_content = subFloatEl.caption_long.content or subFloatEl.caption_long
local caption_content
if subFloatEl.caption_long then
caption_content = subFloatEl.caption_long.content or subFloatEl.caption_long
else
caption_content = pandoc.Inlines({})
end
local caption = full_caption_prefix(parentFloat, subFloatEl)
tappend(caption, caption_content)
local subImgModified = processImg(imgEl, { automatic = true, caption = caption, gallery = gallery })
Expand Down
17 changes: 17 additions & 0 deletions tests/docs/smoke-all/2024/04/25/lightbox-no-caption.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: "lightbox no caption"
lightbox: true
format:
html: {}
docx: {}
---

::: {#fig-multi layout-nrow=3}

![](la-palma-map.png){#fig-a}

![](la-palma-map.png){#fig-b}

Captions (a) bala; (b) bala
:::

0 comments on commit e1b9356

Please sign in to comment.