Closed juliantao closed 7 months ago
I just noticed that this issue is related to #9444 @cderv @gordonwoodhull
Nod, probably the Pandoc upgrade and its nil
s replacing erroneous empty Inlines
.
Thanks for the report & bisect!
I can repro as described. After a "mechanical" fix of the crashing line, another similar bug is exposed in layout/docx.lua
which can also be fixed mechanically.
diff --git a/src/resources/filters/layout/lightbox.lua b/src/resources/filters/layout/lightbox.lua
index a6ca0d0f7..a0479c856 100644
--- a/src/resources/filters/layout/lightbox.lua
+++ b/src/resources/filters/layout/lightbox.lua
@@ -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 })
diff --git a/src/resources/filters/layout/docx.lua b/src/resources/filters/layout/docx.lua
index 52b2491c1..8fb65c458 100644
--- a/src/resources/filters/layout/docx.lua
+++ b/src/resources/filters/layout/docx.lua
@@ -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
However, I am not sure how to isolate this for a test, or alternately, how to add a manuscript project test, so leaving this for now. The described code in an isolated single file does not err.
I don't think this is a dupe of #9444, which encounters a null Does appear to a dupe as pointed out by @cderv! Location is different because of bundling.caption_long
at a different code location.
@gordonwoodhull I think we'd use our older testing procedures, which were to add the test document to tests/docs/...
(not smoke-all
). and then create an explicit render test testRender()
call with the verification code in typescript. For example, https://github.com/quarto-dev/quarto-cli/blob/main/tests/smoke/engine/include-engine-detection.test.ts
Taking this as @cderv showed me how to make a minimal reprex.
Bug description
Since commit bef2e84, when a caption is missing in a multi-figure environment of a manuscript file, the preview/render function is no longer working. The following error is given:
Steps to reproduce
index.qmd
file, add the following figurediv
:Expected behavior
I noticed that the team provided nil protection to some of the environments, such as
callout
andfloat
, but not forlightbox
. See commit b8c82350851d53b1ab73c54c1800284b16af1046Note that if we only have a single figure, even if a caption is missing, a document can still be rendered. The problem occurs when we have multiple figures in a manuscript type document.
Actual behavior
No response
Your environment
No response
Quarto check output
No response