Skip to content

Commit

Permalink
show code blocks that have the class 'fold-show'
Browse files Browse the repository at this point in the history
  • Loading branch information
bblodfon committed Oct 28, 2020
1 parent e40f5cd commit 5a4ed37
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# rtemps 0.8.0

- Add support for specifying some code blocks to be unfolded at initialization for the *Bookdown Lite* Theme

# rtemps 0.7.0

- Bookdown Lite template files are not copied as a Rmarkdown template, only as a Project Bookdown Template
Expand All @@ -12,7 +16,7 @@

# rtemps 0.4.0

- add support for custom info blocks with images (note, tip, warning, caution, important info)
- Add support for custom info blocks with images (note, tip, warning, caution, important info)

# rtemps 0.3.0

Expand Down
8 changes: 8 additions & 0 deletions inst/rstudio/templates/project/resources/hide_code.html
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,14 @@
var rCodeBlocks = $('pre.sourceCode, pre.r, pre.python, pre.bash, pre.sql, pre.cpp, pre.stan');
rCodeBlocks.each(function() {

// if code block has been labeled with class `fold-show`, show the code on init!
var classList = $(this).attr('class').split(/\s+/);
for (var i = 0; i < classList.length; i++) {
if (classList[i] === 'fold-show') {
show = 'hide'
}
}

// create a collapsable div to wrap the code in
var div = $('<div class="collapse r-code-collapse"></div>');
if (show)
Expand Down

0 comments on commit 5a4ed37

Please sign in to comment.