Skip to content

Commit 67c5440

Browse files
committed
revealjs - code line numbers not working when set to "1"
because it was parsed as true.
1 parent 13484ed commit 67c5440

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

news/changelog-1.8.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ All changes included in 1.8:
4242
- ([#12598](https://github.com/quarto-dev/quarto-cli/pull/12598)): Ensure `.fragment` on an image with caption applies to whole figure.
4343
- ([#12716](https://github.com/quarto-dev/quarto-cli/issues/12716)): Correctly resolve `"brand"` set in `theme` configuration for document in subdirectory from project root.
4444
- Use `cdn.jsdelivr.net` for mathjax dependencies to ensure consistent CDN usage across formats. Previously, `cdnjs.cloudflare.com` was used for `revealjs` mathjax dependencies, while `cdn.jsdelivr.net` was used for html format.
45+
- [#13316](https://github.com/quarto-dev/quarto-cli/issues/13316): `code-line-numbers: "1"` correctly highlight the first line now.
4546

4647
### `docx`
4748

src/resources/filters/quarto-pre/line-numbers.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ end
2626
function lineNumbersAttribute(el)
2727
local default = param(constants.kCodeLineNumbers, false)
2828
local lineNumbers = attribute(el, constants.kCodeLineNumbers, default)
29-
if lineNumbers == true or lineNumbers == "true" or lineNumbers == "1" then
29+
-- format that do accept string for this attributes. "1" and "0" should not be parsed as TRUE / FALSE
30+
local acceptStrings = _quarto.format.isRevealJsOutput() and not _quarto.format.isDocusaurusOutput()
31+
if lineNumbers == true or lineNumbers == "true" or (lineNumbers == "1" and not acceptStrings) then
3032
return true
3133
elseif lineNumbers == false or lineNumbers == "false" or lineNumbers == "0" then
3234
return false
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
format: html
3+
_quarto:
4+
tests:
5+
html:
6+
ensureHtmlElements:
7+
- ['pre.sourceCode.number-lines']
8+
- ['#cb1[data-code-line-numbers="1"]']
9+
revealjs:
10+
ensureHtmlElements:
11+
- ['#cb1[data-code-line-numbers="1"]', 'pre.sourceCode.number-lines']
12+
- []
13+
execute:
14+
echo: true
15+
---
16+
17+
```{r}
18+
#| code-line-numbers: "1"
19+
mean(
20+
c(1, 2, 3, 4, 5)
21+
)
22+
```

0 commit comments

Comments
 (0)