Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ All changes included in 1.6:
- ([#10887](https://github.com/quarto-dev/quarto-cli/issues/10887)): Updating default Mathjax used from 2.7.0 to 2.7.9.
- ([#9999](https://github.com/quarto-dev/quarto-cli/issues/9999)): Fix spacing problems of different size elements in columns.
- ([#11146](https://github.com/quarto-dev/quarto-cli/issues/11146)): Fix issue with slide created with `---` and having no title showing up in TOC. Now they don't show up as slide created with empty header e.g. `## `.
- ([#7142](https://github.com/quarto-dev/quarto-cli/issues/7142)): Fix issue in slides with `incremental: true` not working as expected when `code-annotation: hover` or `code-annotation: select`.

## `typst` Format

Expand Down
10 changes: 10 additions & 0 deletions src/resources/filters/modules/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ local kDataCodeCellLines = 'data-code-lines'
local kDataCodeCellAnnotation = 'data-code-annotation'
local kDataCodeAnnonationClz = 'code-annotation-code'
local kCodeAnnotationStyleNone = "none"
local kCodeAnnotationStyleHover = "hover"
local kCodeAnnotationStyleSelect = "select"
local kCodeLine = "code-line"
local kCodeLines = "code-lines"
local kCellAnnotationClass = "cell-annotation"
Expand Down Expand Up @@ -155,6 +157,9 @@ local kBackgroundColorWarning = "fcefdc"
local kBackgroundColorTip = "ccf1e3"
local kBackgroundColorCaution = "ffe5d0"

-- Pandoc classes for incremental flag
local kIncremental = "incremental"
local kNonIncremental = "nonincremental"

return {
kCitation = kCitation,
Expand Down Expand Up @@ -194,6 +199,8 @@ return {
kDataCodeCellAnnotation = kDataCodeCellAnnotation,
kDataCodeAnnonationClz = kDataCodeAnnonationClz,
kCodeAnnotationStyleNone = kCodeAnnotationStyleNone,
kCodeAnnotationStyleHover = kCodeAnnotationStyleHover,
kCodeAnnotationStyleSelect = kCodeAnnotationStyleSelect,
kCodeLine = kCodeLine,
kCodeLines = kCodeLines,
kCellAnnotationClass = kCellAnnotationClass,
Expand Down Expand Up @@ -245,4 +252,7 @@ return {
kBackgroundColorWarning = kBackgroundColorWarning,
kBackgroundColorTip = kBackgroundColorTip,
kBackgroundColorCaution = kBackgroundColorCaution,

kIncremental = kIncremental,
kNonIncremental = kNonIncremental
}
19 changes: 14 additions & 5 deletions src/resources/filters/quarto-pre/code-annotation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,20 @@ function code_annotations()
-- an id counter to provide nice numeric ids to cell
local idCounter = 1

-- the user request code annotations value
local codeAnnotations = param(constants.kCodeAnnotationsParam)

local requireNonIncremental = PANDOC_WRITER_OPTIONS[constants.kIncremental] and (
codeAnnotations == constants.kCodeAnnotationStyleSelect or codeAnnotations == constants.kCodeAnnotationStyleHover
)

-- walk the blocks and look for annotated code
-- process the list top down so that we see the outer
-- code divs first
local code_filter = {
traverse = 'topdown',
Blocks = function(blocks)

-- the user request code annotations value
local codeAnnotations = param(constants.kCodeAnnotationsParam)

-- if code annotations is false, then shut it down
if codeAnnotations ~= false then

Expand Down Expand Up @@ -540,7 +544,7 @@ function code_annotations()
if codeAnnotations ~= constants.kCodeAnnotationStyleNone then
if pendingCodeCell ~= nil then
-- wrap the definition list in a cell
local dlDiv = pandoc.Div({dl}, pandoc.Attr("", {constants.kCellAnnotationClass}))
local dlDiv = pandoc.Div({dl}, pandoc.Attr("", {constants.kCellAnnotationClass, requireNonIncremental and constants.kNonIncremental or nil }))
if is_custom_node(pendingCodeCell) then
local custom = _quarto.ast.resolve_custom_data(pendingCodeCell) or pandoc.Div({}) -- won't happen but the Lua analyzer doesn't know it
custom.content:insert(2, dlDiv)
Expand All @@ -549,7 +553,12 @@ function code_annotations()
end
flushPending()
else
outputBlockClearPending(dl)
if requireNonIncremental then
-- wrap in Non Incremental Div to prevent automatique
outputBlockClearPending(pandoc.Div({dl}, pandoc.Attr("", {constants.kNonIncremental})))
else
outputBlockClearPending(dl)
end
end
else
flushPending()
Expand Down
32 changes: 32 additions & 0 deletions tests/docs/smoke-all/2024/10/23/7142/below.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Code annotaton and incremental
format:
revealjs:
incremental: true
code-annotations: below
_quarto:
tests:
revealjs:
ensureHtmlElements:
- ['dt.fragment', 'dd.fragment']
- []
ensureFileRegexMatches:
- []
- []
---

## First slide

## Slides with annotations

``` python
1 + 1 # <1>
x = 2 # <2>
x + 3 # <3>
```

1. Note 1
2. Note 2
3. Note 3

## Last slide
32 changes: 32 additions & 0 deletions tests/docs/smoke-all/2024/10/23/7142/hover.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Code annotaton and incremental
format:
revealjs:
incremental: true
code-annotations: hover
_quarto:
tests:
revealjs:
ensureHtmlElements:
- []
- ['.fragment']
ensureFileRegexMatches:
- []
- []
---

## First slide

## Slides with annotations

``` python
1 + 1 # <1>
x = 2 # <2>
x + 3 # <3>
```

1. Note 1
2. Note 2
3. Note 3

## Last slide
32 changes: 32 additions & 0 deletions tests/docs/smoke-all/2024/10/23/7142/select.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Code annotaton and incremental
format:
revealjs:
incremental: true
code-annotations: select
_quarto:
tests:
revealjs:
ensureHtmlElements:
- []
- ['.fragment']
ensureFileRegexMatches:
- []
- []
---

## First slide

## Slides with annotations

``` python
1 + 1 # <1>
x = 2 # <2>
x + 3 # <3>
```

1. Note 1
2. Note 2
3. Note 3

## Last slide