Skip to content

Commit

Permalink
Correctly style code chunks with line numbers activated
Browse files Browse the repository at this point in the history
fixes #473
  • Loading branch information
cderv committed Sep 22, 2022
1 parent 59443b9 commit 9c1a1a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: distill
Title: 'R Markdown' Format for Scientific and Technical Writing
Version: 1.5.1
Version: 1.5.2
Authors@R: c(
person("Christophe", "Dervieux", , "cderv@rstudio.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-4474-2498")),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# distill (development version)

- Fix an issue with line numbering on code chunks when `highlight-downlit: false` by tweaking Pandoc's default CSS rules (thanks, \@SES-CE, #473).

# distill 1.5 (CRAN)

- Add support for [CC0](https://creativecommons.org/share-your-work/public-domain/cc0/) license in `creative_commons` (thanks, \@fkohrt, #431).
Expand Down
10 changes: 8 additions & 2 deletions inst/rmarkdown/templates/distill_article/resources/distill.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@
font-size: 14px;
}

/* tweak for Pandoc numbered line within distill */
d-article pre.numberSource code > span {
left: -2em;
}

d-article pre {
font-size: 14px;
}
Expand Down Expand Up @@ -1040,8 +1045,9 @@
$('.distill-force-highlighting-css').parent().remove();

// remove empty line numbers inserted by pandoc when using a
// custom syntax highlighting theme
$('code.sourceCode a:empty').remove();
// custom syntax highlighting theme, except when numbering line
// in code chunk
$('pre:not(.numberLines) code.sourceCode a:empty').remove();

// load distill framework
load_distill_framework();
Expand Down

0 comments on commit 9c1a1a2

Please sign in to comment.