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

Flair interaction with code folding? #44

Open
cttnguyen opened this issue Feb 10, 2023 · 1 comment
Open

Flair interaction with code folding? #44

cttnguyen opened this issue Feb 10, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@cttnguyen
Copy link

I'd like to implement {flair} with code_folding in Rmarkdown. Perhaps I am not going about it correctly, but is there something under the hood that's preventing the two options from working together?

In this example, I set code folding in the YAML, but the produced document does not allow for the flaired chunk to collapse.

---
output: 
  html_document:
    code_folding: show
---
{r how_to_pipe, message = FALSE, warning = FALSE, include = FALSE}
library(flair)
library(dplyr)
library(ggplot2)

iris %>%
  group_by(Species) %>%
  summarize(mean(Sepal.Length))
{r, echo=FALSE}
decorate("how_to_pipe") %>% 
  flair_lines(2)

I have also tried adding this option to my first chunk, but this causes none of the code to appear. This is doubly problematic in that I would like to use an engine (SAS) that does not yet have code folding defined.

(r, python, bash, sql, cpp, stan, and julia). If this is a limitation for you, it can be extended to apply to any language code source block by adding the class foldable via the chunk option class.source, or even setting it globally so that it applies on any code chunk using knitr::opts_chunk$set(class.source = "foldable").

knitr::opts_chunk$set(
   class.source = "foldable"
)
@kbodwin kbodwin added the enhancement New feature or request label Feb 17, 2023
@kbodwin
Copy link
Collaborator

kbodwin commented Feb 17, 2023

Interesting, I hadn't thought of this, it's a great idea. It may be difficult to implement with the way that flaired chunks get produced as "from scratch" html - but I will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants