Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line numbers for code blocks #473

Closed
SES-CE opened this issue Sep 13, 2022 · 3 comments
Closed

Line numbers for code blocks #473

SES-CE opened this issue Sep 13, 2022 · 3 comments
Labels
bug 🐛 Something isn't working next to consider for next release

Comments

@SES-CE
Copy link

SES-CE commented Sep 13, 2022

Hi,

Is it possible to have line numbers in my code blocks using distill?

I'd like to have line numbers for code blocks so I can reference the code in my article made using distill but I have been unable to get them shown in the output successfully.

Searching the web I found an answer for a general output with 'html_output' as in this post.

Using the code from the post it does not directly transfer to a 'distill::distill_article:' output.

---
title: "Untitled"
author: "Unauthored"
date: "1/1/2020"
output:
    distill::distill_article:
    highlight: tango
    
---

```{css, echo = FALSE}
.sourceCode { overflow: visible; }
```


```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


## Line numbers

```{r, attr.source='.numberLines'}
if (TRUE) {
  x <- 1:10
  x + 1
}
```
@cderv
Copy link
Collaborator

cderv commented Sep 13, 2022

This is an issue with downlit r-lib/downlit#133 which is used by distill to highlight code block by default
https://rstudio.github.io/distill/basics.html#syntax-highlighting

Theoretically, it should be possible to make that works by deactivating downlit

---
title: "Untitled"
author: "Unauthored"
date: "1/1/2020"
output:
    distill::distill_article:
      highlight: tango
      highlight_downlit: false
---

```{css, echo = FALSE}
.sourceCode { overflow: visible; }
```


```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


## Line numbers

```{r, attr.source='.numberLines'}
if (TRUE) {
  x <- 1:10
  x + 1
}
```

However, it seems there is some CSS issues.
image

This should be fixed in distill and the former in downlit

Thank you for the report !

@cderv cderv added bug 🐛 Something isn't working next to consider for next release labels Sep 13, 2022
@cderv cderv closed this as completed in 9c1a1a2 Sep 22, 2022
@cderv
Copy link
Collaborator

cderv commented Sep 22, 2022

The styling should be fixed when highlight_downlit = FALSE and line numbering activated.

Thanks for the report

@SES-CE
Copy link
Author

SES-CE commented Sep 22, 2022

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working next to consider for next release
Projects
Archived in project
Development

No branches or pull requests

2 participants