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

Bug in code_folding: show (in YAML) + class.source = 'fold-hide' (in a chunk) hides code for the rest of the document #1905

Closed
3 tasks done
Pozdniakov opened this issue Sep 23, 2020 · 2 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@Pozdniakov
Copy link

I want to do code folding and choose certain chunks where code will be shown initially as it is described here.

However, using code_folding: show in YAML header and class.source = 'fold-hide' in a chunk leads to unexpected behavior: all next chunks of code are hidden too.

When I do code_folding: hide, I encounter the same problem: using class.source = 'fold-hide' hides code both from the selected chunk and all the chunks below.

reprex

---
title: "try code folding"
output:
  html_document:
    code_folding: show
---

 ```{r}
# This source must be shown
 ```

```{r class.source = 'fold-hide'}
# This source must be hidden
```

```{r}
# This source must be shown
```

This results in:

code_folding_issue

##session_info

>  xfun::session_info('rmarkdown')
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.2, RStudio 1.1.463

Locale: ru_RU.UTF-8 / ru_RU.UTF-8 / ru_RU.UTF-8 / C / ru_RU.UTF-8 / ru_RU.UTF-8

Package version:
  base64enc_0.1.3 digest_0.6.25   evaluate_0.14   glue_1.4.2      graphics_4.0.2 
  grDevices_4.0.2 highr_0.8       htmltools_0.5.0 jsonlite_1.7.1  knitr_1.30.1   
  magrittr_1.5    markdown_1.1    methods_4.0.2   mime_0.9        rlang_0.4.7    
  rmarkdown_2.3.9 stats_4.0.2     stringi_1.5.3   stringr_1.4.0   tinytex_0.26   
  tools_4.0.2     utils_4.0.2     xfun_0.17       yaml_2.2.1     

Pandoc version: 1.19.2.1

R Markdown log

  |..........                                                            |  14%
  ordinary text without R code

  |....................                                                  |  29%
label: unnamed-chunk-1
  |..............................                                        |  43%
  ordinary text without R code

  |........................................                              |  57%
label: unnamed-chunk-2 (with options) 
List of 1
 $ class.source: chr "fold-hide"

  |..................................................                    |  71%
  ordinary text without R code

  |............................................................          |  86%
label: unnamed-chunk-3
  |......................................................................| 100%
  ordinary text without R code


/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS try_folding.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output try_folding.html --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable 'theme:bootstrap' --include-in-header /var/folders/mb/3y6vs_2x2m1dzch9wpmd6qk80000gn/T//Rtmp8oTREt/rmarkdown-str9090a0bb667.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --variable code_folding=show --variable code_menu=1 


processing file: try_folding.Rmd
output file: try_folding.knit.md


Output created: try_folding.html

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('rmarkdown'). 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/rmarkdown').
    • 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.


@atusy
Copy link
Collaborator

atusy commented Sep 24, 2020

@Pozdniakov
I'm the one who introduced the feature with the bug...
It will be fixed by #1906.
You may try it by installing rmarkdown by

remotes::install_github('rstudio/rmarkdown#1906')

@yihui yihui closed this as completed in ad2c8fd Sep 24, 2020
@cderv cderv added the bug an unexpected problem or unintended behavior label Sep 24, 2020
jonathan-g added a commit to jonathan-g/rmarkdown that referenced this issue Sep 24, 2020
* rstudio_origin/master:
  fix rstudio#1905: a chunk with the class "fold-hide" should only hide itself (rstudio#1906)
  bump version after merging rstudio#1899
  lua filter -> Lua filter
  Add an argument `lua_filters` to pandoc_options() to store them in the output format object (rstudio#1899)
  recursve into the parent dir at the end
  also suppor dir input in proj_root()
  list.files() with full.names = TRUE (so the files could be read with corret paths), and pass down the `file`/`pattern` arguments in the recursion
  use our own proj_root() instead of introducing a dependency
  rename package_root() to proj_root()
  generalize the package_root() function to work with more types of projects
  Discover site generators in index.Rmd files in parent directories (rstudio#1898)
  only install pkgdown for website build (rstudio#1900)
  Generalize number sections (rstudio#1879)
  enable figure cropping in pdf_document() only when both pdfcrop and ghostscript are found (yihui/knitr#954), and do not limit this feature to non-Windows platforms
  add the citation entry for the R Markdown Cookbook
  add lua filter vignette to pkgdown website (rstudio#1894)
  close rstudio#1889: evaluate the output argument before changing working directory in pandoc_convert() (rstudio#1890)
jonathan-g added a commit to jonathan-g/rmarkdown that referenced this issue Sep 24, 2020
Merge remote-tracking branch 'rstudio_origin/master' into css-slash-fix

# By Yihui Xie (12) and others
# Via GitHub
* rstudio_origin/master: (22 commits)
  fix rstudio#1905: a chunk with the class "fold-hide" should only hide itself (rstudio#1906)
  bump version after merging rstudio#1899
  lua filter -> Lua filter
  Add an argument `lua_filters` to pandoc_options() to store them in the output format object (rstudio#1899)
  recursve into the parent dir at the end
  also suppor dir input in proj_root()
  list.files() with full.names = TRUE (so the files could be read with corret paths), and pass down the `file`/`pattern` arguments in the recursion
  use our own proj_root() instead of introducing a dependency
  rename package_root() to proj_root()
  generalize the package_root() function to work with more types of projects
  Discover site generators in index.Rmd files in parent directories (rstudio#1898)
  only install pkgdown for website build (rstudio#1900)
  Generalize number sections (rstudio#1879)
  enable figure cropping in pdf_document() only when both pdfcrop and ghostscript are found (yihui/knitr#954), and do not limit this feature to non-Windows platforms
  add the citation entry for the R Markdown Cookbook
  add lua filter vignette to pkgdown website (rstudio#1894)
  close rstudio#1889: evaluate the output argument before changing working directory in pandoc_convert() (rstudio#1890)
  tweak news
  require Pandoc >= 1.14
  xfun 0.16 is on CRAN now
  ...

# Conflicts:
#	NEWS.md
@github-actions
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 Mar 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants