{"id":14066373,"url":"https://github.com/carpentries/pegboard","last_synced_at":"2026-01-05T05:58:26.118Z","repository":{"id":39763128,"uuid":"261610295","full_name":"carpentries/pegboard","owner":"carpentries","description":"R6 classes for exploring the content Carpentries Lessons :triangular_ruler:","archived":false,"fork":false,"pushed_at":"2025-02-19T16:23:05.000Z","size":56229,"stargazers_count":6,"open_issues_count":25,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-19T17:26:13.352Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://carpentries.github.io/pegboard","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/carpentries.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["carpentries"],"custom":["https://www.zeffy.com/en-US/donation-form/donate-to-make-a-difference-7497"]}},"created_at":"2020-05-06T00:04:45.000Z","updated_at":"2025-02-19T16:18:56.000Z","dependencies_parsed_at":"2023-09-22T00:03:47.043Z","dependency_job_id":"a6e54a0d-a64c-46e0-9033-88109dccf158","html_url":"https://github.com/carpentries/pegboard","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/carpentries/pegboard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpentries%2Fpegboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpentries%2Fpegboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpentries%2Fpegboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpentries%2Fpegboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carpentries","download_url":"https://codeload.github.com/carpentries/pegboard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpentries%2Fpegboard/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267779922,"owners_count":24143198,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-13T07:05:04.058Z","updated_at":"2026-01-05T05:58:26.092Z","avatar_url":"https://github.com/carpentries.png","language":"R","funding_links":["https://github.com/sponsors/carpentries","https://www.zeffy.com/en-US/donation-form/donate-to-make-a-difference-7497"],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n# {pegboard}: Parse Source Files in The Carpentries Workbench \u003cimg src='man/figures/logo.png' align='right' alt='' width=120 /\u003e\n\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\noptions(width = 300)\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#|\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n\u003c!-- badges: start --\u003e\n[![pegboard status badge](https://carpentries.r-universe.dev/badges/pegboard)](https://carpentries.r-universe.dev)\n[![R-CMD-check status](https://github.com/carpentries/pegboard/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/carpentries/pegboard/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/carpentries/pegboard/branch/main/graph/badge.svg)](https://codecov.io/gh/carpentries/pegboard?branch=main)\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)\n[![CRAN status](https://www.r-pkg.org/badges/version/pegboard)](https://CRAN.R-project.org/package=pegboard)\n\u003c!-- badges: end --\u003e\n\n\u003e [pegboard] is tempered hardboard which is pre-drilled with evenly spaced\n\u003e holes. The holes are used to accept pegs or hooks to support various items,\n\u003e such as tools in a workshop.\n\u003e\n\u003e https://en.wikipedia.org/wiki/Pegboard\n\nThe {pegboard} package is part of [The Carpentries\nWorkbench](https://carpentries.github.io/workbench/) and it's main\nfunctionality is to parse Markdown and R Markdown documents into XML\nrepresentations (via [{tinkr}](https://docs.ropensci.org/tinkr/)). By using XML,\nwe are able to easily arrange and parse the elements of the lessons which makes\ntwo things possible:\n\n - parse and validate the lessons for structural markdown elements\n - translate markdown syntax of Carpentries-style materials from the \n   [styles lesson infrastructure\n   (Jekyll-based)](https://github.com/carpentries/styles) to The Workbench\n   (Pandoc-based) (see the [lesson transition\n   tool](https://github.com/carpentries/lesson-transition#readme) for details)\n\nThere are two [{R6}](https://cran.r-project.org/package=R6) objects in the\npackage:\n\n - Episode: stores the xml content of a single Markdown or R Markdown file.\n   This extends the the [`tinkr::yarn`\n   class](https://docs.ropensci.org/tinkr/reference/yarn.html). See\n   `vignette(\"intro-episode\", package = \"pegboard\")` for more info. \n - Lesson: stores all publishable markdown content as `Episodes` within a\n   lesson. See `vignette(\"intro-episode\", package = \"pegboard\")` for more info.\n\nOne simple usage is getting a summary of the content of an episode. Let's\ninvestigate the contents of [the \"Episode Structure\"\nepisode](https://carpentries.github.io/sandpaper-docs/episodes.html) of the\nWorkbench documentation:\n\n```{r}\nlibrary(\"pegboard\")\nlibrary(\"withr\")\n# Download the file we need ------------------------------------\nsrc \u003c- \"https://raw.githubusercontent.com/carpentries/sandpaper-docs/main/episodes/episodes.Rmd\"\ntmp \u003c- local_tempfile(fileext = \".Rmd\")\ndownload.file(src, tmp)\n\n# Load episode\nep \u003c- Episode$new(tmp)\n# Summary -------------------------------------------------------------\n# confirm that we are using sandpaper and get a summary of the contents\nep$confirm_sandpaper()$summary()\n\n# Validation ----------------------------------------------------------\n# NOTE: a lot of invalid links because files do not exist outside of\n#       the lesson context\nlnk \u003c- ep$validate_links()\nstr(lnk, max.level = 1)\nhdg \u003c- ep$validate_headings()\nstr(hdg, max.level = 1)\ndiv \u003c- ep$validate_divs()\nstr(div, max.level = 1)\n```\n\n## Installation\n\n{pegboard} is not currently on CRAN, but it can be installed from our\n[Carpentries Universe](https://carpentries.r-universe.dev/ui#builds)\n(updated every hour) with the following commands:\n\n``` r\noptions(repos = c(\n  carpentries = \"https://carpentries.r-universe.dev/\", \n  CRAN = \"https://cran.rstudio.com/\"\n))\ninstall.packages(\"pegboard\")\n```\n\n## Example\n \nTo use {pegboard} in the context of The Workbench, you will need to have a\nlesson handy. If you don't have one, you can use the `get_lesson()` function,\nwhich will use [{gert}](https://r-lib.github.io/gert/) to clone a lesson\nrepository to your computer. \n\n(NOTE: this file was last run on `r Sys.time()`)\n\n```{r example, message = FALSE}\nlibrary(\"pegboard\")\nlibrary(\"purrr\")\nlibrary(\"xml2\")\nlibrary(\"fs\")\n\nd \u003c- fs::file_temp(pattern = \"PBREADME\")\nrng \u003c- get_lesson(\"swcarpentry/r-novice-gapminder\", path = d, jekyll = FALSE)\nrng\n\n# Get a summary of all the elements in each episode\nrng$summary()\n\n# Validate lesson elements\nrng$validate_links()\nrng$validate_divs()\nrng$validate_headings() # this is not run by default in sandpaper lessons\n```\n\n### Manipulation \n\nThe XML contents of the lesson are contained within the `$body` element of the\nEpisode object and anything you do to that XML document is retained within the\nobject itself (see the [{tinkr} documentation](https://docs.ropensci.org/tinkr)\nfor more details):\n\n```{r}\nep1 \u003c- rng$episodes[[1]]\nep1$body\nep1$head(20) # show the first 20 lines of the file\nnew_content \u003c- r\"{\n\n#### NEW CONTENT\n\nHello! This is **new markdown content** generated via the \n[{pegboard}](https://carpentries.github.io/pegboard) package that will \nappear above the objectives block!\n\n}\"\nep1$add_md(new_content, where = 0L) \nep1$head(20) # the new content has been added to the top\nep1$headings[[1]] # the first heading is level 4. Let's change that using {xml2}\nxml2::xml_set_attr(ep1$headings[[1]], \"level\", \"2\")\nep1$head(20)\nep1$headings[[1]] # the first heading is now level 2\n# write the file\nep1$write(fs::path_dir(ep1$path), format = \"Rmd\")\nreadLines(ep1$path, 20)\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarpentries%2Fpegboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarpentries%2Fpegboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarpentries%2Fpegboard/lists"}