Skip to content

Commit a68f3f0

Browse files
claude: Fix latent bug in resolveCaptionCitations
Fix a 2021 bug in cites.lua where resolveCaptionCitations() returned boolean instead of Inlines/nil. The Inlines walker expects either a list of Inlines (modified) or nil (no changes), not true/false. This bug was exposed when margin layout changes preserved column-margin classes on FloatRefTarget, causing the previously-unreachable code path to execute. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 35ad750 commit a68f3f0

2 files changed

Lines changed: 10 additions & 14 deletions

File tree

src/resources/filters/layout/cites.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,9 @@ function resolveCaptionCitations(captionContentInlines, inMargin)
151151

152152
if #citeEls > 0 then
153153
tappend(captionContentInlines, citeEls)
154-
return true
155-
else
156-
return false
154+
return captionContentInlines
157155
end
156+
-- return nil implicitly if no changes
158157
end
159158

160159
function marginCitePlaceholderInline(citation)

src/resources/filters/quarto-pre/parsefiguredivs.lua

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -371,17 +371,14 @@ function parse_floatreftargets()
371371
-- Remove layout classes from div
372372
div.classes = div.classes:filter(
373373
function(c) return not layout_classes:includes(c) end)
374-
-- For margin classes, keep on attr so FloatRefTarget can use notefigure
375-
-- For fullwidth classes, strip from attr - columns.lua handles wideblock wrapping
376-
local margin_classes = layout_classes:filter(
377-
function(c) return c == "column-margin" or c == "aside" end)
378-
local fullwidth_classes = layout_classes:filter(
379-
function(c) return c ~= "column-margin" and c ~= "aside" end)
380-
if #fullwidth_classes > 0 then
381-
attr.classes = attr.classes:filter(
382-
function(c) return not fullwidth_classes:includes(c) end)
383-
end
384-
-- margin_classes stay on attr for FloatRefTarget margin placement
374+
-- Strip fullwidth layout classes from attr (columns.lua handles wideblock wrapping)
375+
-- but keep margin classes so FloatRefTarget can use notefigure
376+
attr.classes = attr.classes:filter(function(c)
377+
if c == "column-margin" or c == "aside" then
378+
return true -- keep margin classes
379+
end
380+
return not layout_classes:includes(c) -- strip other layout classes
381+
end)
385382
end
386383
-- If no cell-output-display (e.g., listings with echo:true eval:false),
387384
-- keep layout_classes on attr so the FloatRefTarget inherits them

0 commit comments

Comments
 (0)