Repository navigation
Description
Hi,
I recently searched for an option to have buttons that hide the R code output since it was not supported via a simple option in bookdown::gitbook. Using this stackoverflow answer I implemented somewhat of a hacked version with nice CSS (from the united bootstrap theme) for the buttons and it looks like this. For the individual R chunks the solution is nice, though for the hide-show-all button that is in the right-up corner, the solution is sowewhat (!) hacked (position: fixed in the CSS). But it works so it's good enough for me :)
I was considering though that it would be really nice, to have the option integrated globally in gitbook, where the hide-show-all button would be in the toolbar (like all the other sharing buttons - github, fb, etc.) and the config would look somewhat like this:
bookdown::gitbook:
config:
show_codefolding_buttons: true # to show all the buttons
hide_code: true # initial configuration, no R code is shown if above is true
BR, John.
By filing an issue to this repo, I promise that
- I have fully read the issue guide at https://yihui.name/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('bookdown'). 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('rstudio/bookdown'). - 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.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
[-]Support for code folding buttons (suggestion)[/-][+]Feature request: Support for code folding buttons[/+]bblodfon commentedon Mar 9, 2020
Based on the previosuly-mentioned stackoverflow answer, I implemented an R package with a bookdown template that uses a code-folding buttons. Check it here: https://github.com/bblodfon/rtemps.
This is more like a quick-hacked-working solution - I don't know if this should be implemented as part of the main
bookdownpackage or not at this point.cderv commentedon Mar 24, 2021
Thanks for this suggestion. I believe this is duplicated of #395.
We would definitely welcome a PR so that it is supported in
bookdown::gitbook(). It is a feature that has a lot of 👍Are you willing to submit a PR ?
bblodfon commentedon Mar 24, 2021
Hi @cderv , as I explain in the original post above it is a very hacked solution the one I implemented in
rtemps. If it's still welcomed though, I will need the time to look at the bookdown code, which currently I don't have. Maybe during summer or afterwards as a side-project, but no guarantees!cderv commentedon Mar 24, 2021
That is ok. We may look into ourself before then. Thanks for your quick answer.
atusy commentedon Mar 31, 2021
Let me give people a prototype.
Just like
html_document, initial state can be "show" or "hide" by editing{"initial-state": "show"}atusy commentedon Mar 31, 2021
I think the above JS is light enough to be an optional feature of
rmarkdown::html_vignetteas well.So I'd like to suggest include this feature as
htmlDependencyin the rmarkdown package, and bookdown package depends on it.cderv commentedon Mar 31, 2021
@atusy you can open a feature request in rmarkdown linking to this one so that it could be consider there.
I know
html_vignette()is designed to be lightweight but it seems small enough to be added when opt-in.Thank you for all your ideas !
atusy commentedon Mar 31, 2021
Great. I will.
isaactpetersen commentedon Feb 16, 2022
Any update on this? I'm very interested in bookdown support for code folding using collapsible code chunks. This would prevent users from having to read through many lines of code (unless they want to), while still making the code available.
atusy commentedon Feb 16, 2022
Sorry, I was totally forgetting about this issue.
I assigned myself and will work on this or next weekends.
atusy commentedon Feb 17, 2022
2 remaining items
atusy commentedon Mar 31, 2022
Finally, I am working on this issue.
Once the PR is merged in rmarkdown, we can apply the feature to bookdown, too.
rstudio/rmarkdown#2340
isaactpetersen commentedon Mar 31, 2022
Great, thanks very much for the update and the addition to rmarkdown! Will be exciting to implement this in bookdown. Much appreciated.
isaactpetersen commentedon Jul 13, 2022
@atusy Is codefolding able to incorporated into
bookdownnow that it has been merged intormarkdown? Any updates on this would be greatly appreciated. Thanks!atusy commentedon Aug 14, 2022
@isaactpetersen Yes, it should be. I've been less active these days... I'll make some time this week.
atusy commentedon Aug 14, 2022
@isaactpetersen
I opened a PR. You can try it with
remotes::install_github("rstudio/bookdown#1368")close #764: gitbook() gains the `code_folding` option (#1368)
isaactpetersen commentedon Aug 16, 2022
Great, thank you! @atusy
github-actions commentedon Feb 15, 2023
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.