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

fix a chunk with fold-hide should only hide itself (closes #1905) #1906

Merged
merged 4 commits into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ rmarkdown 2.4

- For the output format `pdf_document`, the option `fig_crop` will not be enabled unless both the programs `pdfcrop` and `ghostscript` are found (thanks, @dalupus, yihui/knitr#954).

- Fix a bug that a chunk with `fold-hide` class hides rest of the chunks despite of `html_document(code_folding = "show")` (thanks, @atusy, #1906)

rmarkdown 2.3
================================================================================
Expand Down
8 changes: 4 additions & 4 deletions inst/rmd/h/navigation-1.1/codefolding.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ window.initializeCodeFolding = function(show) {

// create a collapsable div to wrap the code in
var div = $('<div class="collapse r-code-collapse"></div>');
show = (show || $(this).hasClass('fold-show')) && !$(this).hasClass('fold-hide');
if (show) div.addClass('in');
var showThis = (show || $(this).hasClass('fold-show')) && !$(this).hasClass('fold-hide');
if (showThis) div.addClass('in');
var id = 'rcode-643E0F36' + currentIndex++;
div.attr('id', id);
$(this).before(div);
$(this).detach().appendTo(div);

// add a show code button right above
var showCodeText = $('<span>' + (show ? 'Hide' : 'Code') + '</span>');
var showCodeText = $('<span>' + (showThis ? 'Hide' : 'Code') + '</span>');
var showCodeButton = $('<button type="button" class="btn btn-default btn-xs code-folding-btn pull-right"></button>');
showCodeButton.append(showCodeText);
showCodeButton
.attr('data-toggle', 'collapse')
.attr('data-target', '#' + id)
.attr('aria-expanded', show)
.attr('aria-expanded', showThis)
.attr('aria-controls', id);

var buttonRow = $('<div class="row"></div>');
Expand Down