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

add folding option for messages and warnings #2227

Closed
3 tasks done
rkb965 opened this issue Feb 11, 2023 · 4 comments
Closed
3 tasks done

add folding option for messages and warnings #2227

rkb965 opened this issue Feb 11, 2023 · 4 comments
Labels
question Questions (which should belong to forums instead of Github)

Comments

@rkb965
Copy link

rkb965 commented Feb 11, 2023

Hi all -- thank you for your wonderful work on knitr

Feature request: Could you add message-folding and warning-folding options, in the vein of code-folding?

Justification: I use knitr/rmarkdown pretty exclusively for sharing analyses with colleagues. I'd like to be able to show a relatively clean document with the option to expand messages/warnings for input from my collaborators. When I leave messages/warnings in, they can be overwhelming and distracting from the primary output, but when I remove them, I miss the opportunity for some useful input (eg on things like model fit messages or tidylog messages about dropped observations, etc). I'd appreciate the opportunity to generally fold them and expand as relevant in a discussion.

Thank you so much for considering this!


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('knitr'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/knitr').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@rkb965 rkb965 changed the title ft request: add folding option for messages and warnings add folding option for messages and warnings Feb 11, 2023
@yihui
Copy link
Owner

yihui commented May 19, 2023

Hi, you can achieve this by setting class.message and class.warning options, e.g.,

---
title: "Test"
output:
  html_document:
    code_folding: show
---

```{r, setup, include=FALSE}
knitr::opts_chunk$set(class.message='foldable fold-hide', class.warning='foldable fold-hide')
```

```{r}
message('Hello message!')
warning('Hello warning!')
```

References:

@yihui yihui added the question Questions (which should belong to forums instead of Github) label May 19, 2023
@rkb965
Copy link
Author

rkb965 commented May 25, 2023

Wow, thanks @yihui ! It looks like that has existed for quite a long time without me ever running across it. Thank you!

btw -- I see it described clearly in your second link but it wasn't clear to me from the linked bit of the cookbook that class.message and class.warning existed (it is absolutely mentioned here: https://bookdown.org/yihui/rmarkdown-cookbook/attr-output.html#attr-output)

I'm going to be using this extensively. Thank you for the wonderful package and documentation, and thank you for taking the time to respond to this question.

@yihui
Copy link
Owner

yihui commented May 26, 2023

You are welcome! Thank you for the patience in the long waiting! I understand that sometimes it's not easy to connect the dots. To be honest, even I was not aware of this solution in the beginning. I thought it was a new feature that I would have to implement, but after a while I suddenly recalled @atusy's foresight rstudio/rmarkdown#1835.

The solution has a little imperfection, which will be improved by rstudio/rmarkdown#2489.

Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Questions (which should belong to forums instead of Github)
Projects
None yet
Development

No branches or pull requests

2 participants