Skip to content

Commit e1f8b9b

Browse files
committed
fix: shift annotated lines past the fence of a fenced echo block with startFrom
1 parent 3f6374e commit e1f8b9b

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ local function resolveCellAnnotes(codeBlockEl, processAnnotation)
120120

121121
local outputs = pandoc.List({})
122122
local i = 1
123-
local offset = codeBlockEl.attr.attributes['startFrom'] or defaultStartLine
123+
-- the injected fence line of a fenced echo block counts as one line before the code
124+
local offset = (tonumber(codeBlockEl.attr.attributes['startFrom']) or 1) + defaultStartLine - 1
124125
for line in toLines(code) do
125126

126127
-- Look and annotation
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: Fenced echo with startFrom
3+
format:
4+
typst:
5+
keep-typ: true
6+
code-annotations: true
7+
_quarto:
8+
tests:
9+
typst:
10+
noErrorsOrWarnings: default
11+
ensureTypstFileRegexMatches:
12+
-
13+
- 'Skylighting\(cell-id: "annotated-cell-1", annotations: \("2": 1\)'
14+
- 'quarto-annotation-item\("annotated-cell-1"'
15+
-
16+
- 'quarto-code-annotations:'
17+
---
18+
19+
```{{python}} {startFrom="5"}
20+
x = 1 # <1>
21+
```
22+
23+
1. Assign x.

0 commit comments

Comments
 (0)