Hi Steve,
I have also encountered this issue in my notes, where sometimes I want to refer to the code (was the red line really model 2?) but otherwise it can be in the way. Like you say, this is already straightforward with javascript. The implementation will depend on how the markdown parser renders html code-blocks though, so it is probably best done outside knitr, which in such a workflow just generates the markdown agnostic of how it is parsed.
I have a few examples of such javascript in my notebook; e.g. click "toggle code" on the sidebar: http://carlboettiger.info/2013/04/27/comparison-of-nonparametric-and-parametric-approaches.html
clearly a richer version could be implemented, or collapsing code blocks individually, but I haven't had time to play with it much. Anyway see the javascript and html button if you're interested; and thanks for sharing your thoughts.
Cheers,
Carl
Howdy,Perhaps a useful idea for the future:I'm using Rmarkdown more and more to generate reports from different data analyses at different stages of "readiness".I find that it is helpful to include more code chunks than normal in early/beta versions of an analysis to help facilitate talking through the analysis in something like a lab meeting setting.While having certain code chunks easily readable is handy to kick ideas around during a presentation, it can sometimes be a bit much. I think it would be handy to include a javascript-powered option to embed `[ show | hide ]` links at the top (or bottom) of code chunks that you could click to alternatively hide a chunk when it is being shown, or expand a hidden chunk.Not sure how hard that'd be to add, but just something I thought might be handy. I imagine it is "easy enough" to write a post-processing script that reads in the html output from knit-ing an *.Rmd file and decorating it w/ the appropriate javascript if its too onerous to include somewhere in the Rmd -> md -> html workflow.Just a thought,-steve--
You received this message because you are subscribed to the Google Groups "knitr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knitr+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
<input type=button class=hideshow></input>
<script>$( "input.hideshow" ).each( function ( index, button ) { button.value = 'Hide'; $( button ).click( function () { var target = this.nextSibling ? this : this.parentNode; target = target.nextSibling.nextSibling; if ( target.style.display == 'block' || target.style.display == '' ) { target.style.display = 'none'; this.value = 'Show'; } else { target.style.display = 'block'; this.value = 'Hide'; } } );} );</script>