Skip to content

Commit 8e5420d

Browse files
authored
another request from #1602: use the fold-hide class to hide the code blocks initially (#1798)
1 parent 65dd144 commit 8e5420d

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ rmarkdown 2.2
55

66
- Floating TOC can now distinguish upper/lower-cases (thanks, @atusy, #1783).
77

8+
- When `code_folding='show'` for the output format `html_document`, code blocks can be individually hidden initially by specifying the chunk option `class.source='fold-hide'` (thanks, @atusy, #1798).
9+
810

911
rmarkdown 2.1
1012
================================================================================

inst/rmd/h/navigation-1.1/codefolding.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ window.initializeCodeFolding = function(show) {
2222

2323
// create a collapsable div to wrap the code in
2424
var div = $('<div class="collapse r-code-collapse"></div>');
25-
if (show || $(this)[0].classList.contains('fold-show'))
26-
div.addClass('in');
25+
show = (show || $(this).hasClass('fold-show')) && !$(this).hasClass('fold-hide');
26+
if (show) div.addClass('in');
2727
var id = 'rcode-643E0F36' + currentIndex++;
2828
div.attr('id', id);
2929
$(this).before(div);

0 commit comments

Comments
 (0)