![]() Thanks again to Sébastien Rochette for working out this solution and for graciously troubleshooting my attempt at implementation. If not, questions, corrections, and clarifications are welcome. Set codefolding_nobutton: true to turn off the “Show/hide code” button at the top of the post (as in the present post).Set codefolding_show: hide to hide the code blocks in the post (as in this post).Set disable_codefolding: true to turn off code folding for the post.To over-ride the defaults, you can also set the parameters in the YAML header of any post: The above parameters are defaults for your entire site. Set it to true to disable the button but keep the other code folding functionality. codefolding_nobutton controls whether the “Show/hide code” button will appear at the top of posts that include code blocks.If your previous posts have lots of code in them, set the default to show to minimize changes in the appearance of your site. codefolding_show controls whether code blocks will be shown or hidden by default.Set it to true to disable code folding globally. disable_codefolding controls whether to load the code folding scripts on your site.The config.toml file now has three parameters that control code folding: # Set to true to exclude the "Show/hide all" buttonĪlso edit the custom_css parameter so that the codefolding.css file will get loaded: custom_css = # Set to "hide" or "show" all codes by default Modify your config.toml file (in the base directory of your site) to include the following lines: # Set to true to disable code folding Add the following lines of code to the file: If you do not already have a file head_custom.html in the \layouts\partials directory, create it. This is the css for the buttons that will appear on your posts.Īdd the file article_footer_js.html to the \layouts\partials directory of your site.Īdd the file header_maincodefolding.html to the \layouts\partials directory of your site. Add the files transition.js, collapse.js, and dropdown.js from bootstrap.Īlso add Sébastien’s codefolding javascript, codefolding.js.Ĭreate a folder called css under the \static directory of your site. Create a folder called js under the \static directory of your site. You’ll first need to pull in some javascript assets. I don’t know javascript to save my life, and my only contribution is to write down the instructions in what I hope is a coherent fashion, so that you too can soon be doing the happy code folding dance if you so desire. To be totally clear, all of the hard bits of this were solved by Sébastien. ![]() In this post, I’ll lay out how to make Sébastien’s code folding feature work with the Academic theme. Now all of my posts have working code folding! To my amazement and good fortune, Sébastien swooped in with a pull request that cleaned up my blundering attempts at implementation. I have been putzing around, trying to get it to work with my blog, which uses the Hugo Academic theme-alas, to no avail. I recently ran across an implementation of codefolding for blogdown, developed by Sébastien Rochette. However, the feature is not supported in blogdown, the popular Rmarkdown-based website/blog creation package. Rmarkdown documents now have a very nifty code folding option, which allows the reader of a compiled html document to toggle whether to view or hide code chunks. See my updated instructions to get it working with newer versions of Academic. Background colour of the chunk, rgb and HTML formats can be used, the default value is "#F7F7F7".This post describes an implementation of code folding for an older version of the Academic Theme. Can take other parameters, echo=2:3 prints only the second and third lines echo=-2:-3 excludes the second and third lines only. hold Holds the output results and to push them at the end of the chunk.markup Use L aT eX for format the output.Changes the behaviour of the results generated by the R code, possible values are We have put all the article code fragments into a project that you can Open on Overleaf Once the script is imported, you can print a chunk using the label you set after #. or switch format for publication using htmldocument instead if this format suits. output : htmlnotebook : codefolding: hide. Then you can either modify the default option in your yaml header. Each one of the argument of the htmlnotebook function can be specified in a yaml header. The first chunk is not printed, is only used to import the script with the command read_chunk("mycode.R"), that's why the option echo=FALSE is set. You can see all the options of the format in the help page.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |