An open API service indexing awesome lists of open source software.

https://github.com/rundel/parsermd


https://github.com/rundel/parsermd

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README",
out.width = "100%"
)

options(width = 80)
```

# parsermd

[![CRAN status](https://www.r-pkg.org/badges/version/parsermd)](https://CRAN.R-project.org/package=parsermd)
[![R-CMD-check](https://github.com/rundel/parsermd/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rundel/parsermd/actions/workflows/R-CMD-check.yaml)

The goal of parsermd is to extract the content of an R Markdown file to allow for programmatic interactions with the document's contents (i.e. code chunks and markdown text). The goal is to capture the fundamental structure of the document and as such we do not attempt to parse every detail of the Rmd. Specifically, the yaml front matter, markdown text, and R code are read as text lines allowing them to be processed using other tools.

## Installation

`parsermd` can be installed from CRAN with:

```r
install.packages("parsermd")
```

You can install the latest development version of `parsermd` from [GitHub](https://github.com/rundel/parsermd) with:

```r
remotes::install_github("rundel/parsermd")
```

```{r}
library(parsermd)
```

## Basic Usage

For more details see the getting started [vignette](https://rundel.github.io/parsermd/articles/parsermd.html) or any of the topic specific articles.

```{r example}
(rmd = parsermd::parse_rmd(system.file("examples/minimal.Rmd", package = "parsermd")))

as_tibble(rmd)

rmd_select(rmd, by_section("Content"))

rmd_select(rmd, by_section(c("Content", "*"))) |>
rmd_select(has_type(c("rmd_chunk", "rmd_heading")))

rmd_select(rmd, "pressure")

rmd_select(rmd, 1:3)
```