Wrap horizontal code overflow in Quarto revealjs

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

Wrap horizontal code overflow in Quarto revealjs

问题

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

  1. ---
  2. format: revealjs
  3. ---
  4. ## 一个标题
  5. ```{r}
  6. #| echo: true
  7. #| code-overflow: wrap
  8. 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)))
  9. #这应该被包裹。

Wrap horizontal code overflow in Quarto revealjs

  1. [![enter image description here][1]][1]
  2. [1]: https://i.stack.imgur.com/FKigp.png
  3. <details>
  4. <summary>英文:</summary>
  5. 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`:
  6. ---
  7. format: revealjs
  8. ---
  9. ## A title
  10. ```{r}
  11. #| echo: true
  12. #| code-overflow: wrap
  13. 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)))
  14. #This should be wrapped.
  15. ```
  16. [![enter image description here][1]][1]
  17. [1]: https://i.stack.imgur.com/FKigp.png
  18. </details>
  19. # 答案1
  20. **得分**: 2
  21. 你可以使用 [`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` 渲染时才可行):
  22. ```{r}
  23. #| eval: false
  24. #| echo: true
  25. #| tidy: true
  26. #| tidy.opts: { width.cutoff: 60 }
  27. 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):

  1. ---
  2. format: revealjs
  3. ---
  4. ## A title
  5. Here is some example code
  6. ```{r}
  7. #| eval: false
  8. #| echo: true
  9. #| tidy: true
  10. #| tidy.opts: { width.cutoff: 60 }
  11. 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)))
  12. ```

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:

确定