Skip to content

Commit 6f50227

Browse files
committed
If output location is slide, keep annotations in place
Fixes #4213
1 parent 2966649 commit 6f50227

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/resources/filters/quarto-pre/code-annotation.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ local hasAnnotations = false;
6969

7070
local kCellAnnotationClass = "cell-annotation"
7171

72+
73+
function isAnnotationCell(el)
74+
return el and el.t == "Div" and el.attr.classes:includes(kCellAnnotationClass)
75+
end
7276
-- annotations appear at the end of the line and are of the form
7377
-- # <1>
7478
-- where they start with a comment character valid for that code cell

src/resources/filters/quarto-pre/output-location.lua

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,20 @@ end
2121

2222
-- note: assumes that outputLocationCellHasCode has been called
2323
local function partitionCell(el, outputClass)
24-
local codeDiv = pandoc.Div({ el.content[1] }, el.attr)
25-
local outputDiv = pandoc.Div(tslice(el.content, 2, #el.content), el.attr)
24+
-- compute the code div, being sure to bring the annotations
25+
-- along with the code
26+
local code = { el.content[1] }
27+
local outputIndex
28+
if isAnnotationCell(el.content[2]) then
29+
tappend(code, {el.content[2]})
30+
outputIndex = 3
31+
else
32+
outputIndex = 2
33+
end
34+
35+
local codeDiv = pandoc.Div(code, el.attr)
36+
37+
local outputDiv = pandoc.Div(tslice(el.content, outputIndex, #el.content), el.attr)
2638
outputDiv.attr.identifier = ""
2739
outputDiv.attr.classes:insert(outputClass)
2840
return { codeDiv, outputDiv }

0 commit comments

Comments
 (0)