-
Notifications
You must be signed in to change notification settings - Fork 4
/
README.Rmd
64 lines (43 loc) · 1.8 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README",
out.width = "100%"
)
options(width = 80)
library(magrittr)
```
# parsermd
<!-- badges: start -->
[![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)
<!-- badges: end -->
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("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)
```