Skip to content

Flair interaction with code folding? #44

Open
@cttnguyen

Description

@cttnguyen

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"
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions