Skip to content

Commit

Permalink
fix #1905: a chunk with the class "fold-hide" should only hide itself (
Browse files Browse the repository at this point in the history
  • Loading branch information
atusy authored Sep 24, 2020
1 parent 80ae1c2 commit ad2c8fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ 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).

- Fixed a bug that a chunk with a class `fold-hide` hides the rest of the chunks even the output format setting `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

0 comments on commit ad2c8fd

Please sign in to comment.