Search code examples
roverflowquartoreveal.js

Wrap horizontal code overflow in Quarto revealjs


Is there a way to have long lines of code wrapped in Quarto, revealjs output? code-overflow: wrap, which works for html output does not seem to work in revealjs:

---
format: revealjs
---

## A title

```{r}
#| echo: true
#| code-overflow: wrap
multipoint <- sf::st_multipoint(rbind(c(3.2,4), c(3,4.6), c(3.8,4.4), c(3.5,3.8), c(3.4,3.6), c(3.9,4.5)))
#This should be wrapped.
```

enter image description here


Solution

  • You can use the width.cutoff property (only a viable option if you render via knitr):

    ---
    format: revealjs
    ---
    
    ## A title
    
    
    Here is some example code
    
    ```{r}
    #| eval: false
    #| echo: true
    #| tidy: true
    #| tidy.opts: { width.cutoff: 60 }
    multipoint <- sf::st_multipoint(rbind(c(3.2,4), c(3,4.6), c(3.8,4.4), c(3.5,3.8), c(3.4,3.6), c(3.9,4.5)))
    ```
    

    enter image description here