Skip to content

Commit 4bba7f4

Browse files
authored
Merge pull request #13317 from quarto-dev/fix/revealjs/code-line-numbers
2 parents a4859d5 + 75717b5 commit 4bba7f4

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

news/changelog-1.8.md

Lines changed: 5 additions & 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

@@ -70,6 +71,10 @@ All changes included in 1.8:
7071

7172
- ([#12676](https://github.com/quarto-dev/quarto-cli/issues/12676)): Add support for rendering layout panels that are not floats.
7273

74+
### `docusaurus-md`
75+
76+
- [#13316](https://github.com/quarto-dev/quarto-cli/issues/13316): `code-line-numbers: "1"` correctly highlight the first line now.
77+
7378
## Projects
7479

7580
### `website`

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() or _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: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: highlight first line
3+
format: html
4+
_quarto:
5+
tests:
6+
html:
7+
ensureHtmlElements:
8+
- ['pre.sourceCode.number-lines']
9+
- ['#cb1[data-code-line-numbers="1"]']
10+
revealjs:
11+
ensureHtmlElements:
12+
- ['#cb1[data-code-line-numbers="1"]', 'pre.sourceCode.number-lines']
13+
- []
14+
docusaurus-md:
15+
ensureFileRegexMatches:
16+
- ['[`]{3}r \{1\} showLineNumbers']
17+
- []
18+
execute:
19+
echo: true
20+
---
21+
22+
```{r}
23+
#| code-line-numbers: "1"
24+
mean(
25+
c(1, 2, 3, 4, 5)
26+
)
27+
```

0 commit comments

Comments
 (0)