{"id":13400508,"url":"https://github.com/ijlyttle/codefolder","last_synced_at":"2025-03-23T06:31:07.886Z","repository":{"id":150080188,"uuid":"218811138","full_name":"ijlyttle/codefolder","owner":"ijlyttle","description":"Enable per-page code-folding for Bookdown and Distill","archived":false,"fork":false,"pushed_at":"2019-11-01T03:23:36.000Z","size":14,"stargazers_count":16,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-14T23:53:33.226Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ijlyttle.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-10-31T16:31:24.000Z","updated_at":"2022-08-27T18:26:00.000Z","dependencies_parsed_at":"2023-06-05T02:30:13.984Z","dependency_job_id":null,"html_url":"https://github.com/ijlyttle/codefolder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ijlyttle%2Fcodefolder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ijlyttle%2Fcodefolder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ijlyttle%2Fcodefolder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ijlyttle%2Fcodefolder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ijlyttle","download_url":"https://codeload.github.com/ijlyttle/codefolder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245066496,"owners_count":20555402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T19:00:52.776Z","updated_at":"2025-03-23T06:31:07.469Z","avatar_url":"https://github.com/ijlyttle.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# codefolder\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/codefolder)](https://CRAN.R-project.org/package=codefolder)\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)\n[![Travis build status](https://travis-ci.org/ijlyttle/codefolder.svg?branch=master)](https://travis-ci.org/ijlyttle/codefolder)\n\u003c!-- badges: end --\u003e\n\nThe goal of codefolder is to provide \"aftermarket\" code-folding capabilty for [bookdown](https://bookdown.org/yihui/bookdown) and [distill](https://rstudio.github.io/distill). The operative code is based on this Stack Overflow [answer](https://stackoverflow.com/a/45501553) by Sébastien Rochette. \n\n## Installation\n\nYou can install the delevopment version of codefolder from [GitHub](https://github.com/ijlyttle/codefolder) with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"ijlyttle/codefolder\")\n```\n\n## Example\n\nThis is a quick way to enable code-folding, for an entire page, on a page-by-page basis. \n\nThe idea is to put an Rmd-chunk near the top of a page. When rendered, the chunk places a button in the right margin which can be used to show or hide code.\n\nThere is a function each for Bookdown and Distill. The main argument is `init`, which indicates if you want, initially, to `\"show\"` or `\"hide\"` the code. The other arguments are `query`, the CSS selector for to match the code elements, and the `style` to the button.\n\nBookdown:\n\n````\n`r ''````{r codefolder, echo=FALSE, results='asis'}\ncodefolder::bookdown(init = \"hide\")\n```\n````\n\nDistill:\n\n````\n\u003caside\u003e\n`r ''````{r codefolder, echo=FALSE, results='asis'}\ncodefolder::distill(init = \"hide\")\n```\n\u003c/aside\u003e\n````\n\nIf you like, you can create these as RStudio [code snippets](https://support.rstudio.com/hc/en-us/articles/204463668-Code-Snippets) for markdown. I use `cfb` and `cfd` as my short-codes.\n\nIt will be up to you to add some CSS according to your tastes.\n\n## Code of Conduct\n\nPlease note that the 'codefolder' project is released with a\n[Contributor Code of Conduct](CODE_OF_CONDUCT.md).\nBy contributing to this project, you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fijlyttle%2Fcodefolder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fijlyttle%2Fcodefolder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fijlyttle%2Fcodefolder/lists"}