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

chunk option class.source to add CSS class to flaired code #27

Open
dcossyleon opened this issue Oct 7, 2020 · 0 comments
Open

chunk option class.source to add CSS class to flaired code #27

dcossyleon opened this issue Oct 7, 2020 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@dcossyleon
Copy link
Contributor

Hello!

I'm interested in adding a CSS class to the flaired code chunk in my learnr Rmd. To do this, I have tried using the code chunk option class.source.

---
title: "Flair Test in LearnR"
output: learnr::tutorial
runtime: shiny_prerendered
---

```{r setup, include=FALSE}
library(learnr)
library(flair)
library(tidyverse)
```

```{r how_to_pipe, include = FALSE}
iris %>%
  group_by(Species) %>%
  summarize(mean(Sepal.Length))
```

```{r, echo = FALSE}
decorate("how_to_pipe", class.source = "r") %>% 
  flair("%>%")
```

But the outcome is this error:

Quitting from lines NA-5 (Lesson1.Rmd) 
Error in eval(x, envir = envir) : object 'r' not found
Calls: <Anonymous> ... process_group.block -> call_block -> eval_lang -> eval -> eval
Execution halted

I have also tried this chunk option with the decorate_code() function. In that case the .Rmd does knit, but the flaired chunk and its output disappear. I am working in LearnR, but this chunk option is similarly unrecognized in regular .Rmd, too.

Specifically, I am trying to add this CSS class so that I can restore the grey-background styling that seems to be stripped in flaired code chunks within LearnR (which may or may not be a related issue?):

image

Adding"class=r" to the <pre> tag containing the chunk content restores the default grey background that easily distinguishes it from other output like messages, warnings, etc. which have a white background)

image

@kbodwin kbodwin added enhancement New feature or request help wanted Extra attention is needed labels Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants