Wrap horizontal code overflow in Quarto revealjs

huangapple go评论58阅读模式
英文:

Wrap horizontal code overflow in Quarto revealjs

问题

在Quarto中,是否有一种方法可以将长行代码包裹在revealjs输出中?code-overflow: wrap,它在html输出中有效,似乎在revealjs中不起作用:

---
format: revealjs
---

## 一个标题

```{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)))
#这应该被包裹。

Wrap horizontal code overflow in Quarto revealjs


[![enter image description here][1]][1]

[1]: https://i.stack.imgur.com/FKigp.png

<details>
<summary>英文:</summary>

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 &lt;- 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][1]][1]


  [1]: https://i.stack.imgur.com/FKigp.png

</details>


# 答案1
**得分**: 2

你可以使用 [`width.cutoff`](https://stackoverflow.com/questions/26210656/in-r-markdown-in-rstudio-how-can-i-prevent-the-source-code-from-running-off-a-p) 属性(仅当通过 `knitr` 渲染时才可行):

```{r}
#| eval: false
#| echo: true
#| tidy: true
#| tidy.opts: { width.cutoff: 60 }
multipoint &lt;- 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)))

Wrap horizontal code overflow in Quarto revealjs

英文:

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 &lt;- 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)))
```

Wrap horizontal code overflow in Quarto revealjs

huangapple
  • 本文由 发表于 2023年6月5日 20:33:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76406452.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定