@@ -142,6 +142,11 @@ local function latexListPlaceholder(number)
142142 return ' 5CB6E08D-list-annote-' .. number
143143end
144144
145+ local function toLines (s )
146+ if s :sub (- 1 )~= " \n " then s = s .. " \n " end
147+ return s :gmatch (" (.-)\n " )
148+ end
149+
145150-- Finds annotations in a code cell and returns
146151-- the annotations as well as a code cell that
147152-- removes the annotations
@@ -153,12 +158,14 @@ local function resolveCellAnnotes(codeBlockEl, processAnnotation)
153158 if annotationProvider ~= nil then
154159 local annotations = {}
155160 local code = codeBlockEl .text
156- local lines = split ( code , " \n " )
161+
157162 local outputs = pandoc .List ({})
158- for i , line in ipairs (lines ) do
163+ local i = 1
164+ for line in toLines (code ) do
159165
160166 -- Look and annotation
161167 local annoteNumber = annotationProvider .annotationNumber (line )
168+
162169 if annoteNumber then
163170 -- Capture the annotation number and strip it
164171 local annoteId = toAnnoteId (annoteNumber )
@@ -172,11 +179,15 @@ local function resolveCellAnnotes(codeBlockEl, processAnnotation)
172179 else
173180 outputs :insert (line )
174181 end
182+ i = i + 1
175183 end
176184
185+ quarto .log .output (outputs )
186+ quarto .log .output (annotations )
187+
177188 -- if we capture annotations, then replace the code source
178189 -- code, stripping annotation comments
179- if # annotations > 0 then
190+ if annotations and next ( annotations ) ~= nil then
180191 local outputText = " "
181192 for i , output in ipairs (outputs ) do
182193 outputText = outputText .. output .. ' \n '
281292function processAnnotation (line , annoteNumber , annotationProvider )
282293 -- For all other formats, just strip the annotation- the definition list is converted
283294 -- to be based upon line numbers.
284- local stripped = annotationProvider .stripAnnotation (line , annoteNumber )
295+ local stripped = annotationProvider .stripAnnotation (line , annoteNumber )
285296 return stripped
286297end
287298
0 commit comments