-
Notifications
You must be signed in to change notification settings - Fork 5
/
README.Rmd
85 lines (59 loc) · 2.28 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
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%"
)
```
# lightparser
<!-- badges: start -->
[![R-CMD-check](https://github.com/ThinkR-open/lightparser/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ThinkR-open/lightparser/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/ThinkR-open/lightparser/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ThinkR-open/lightparser?branch=main)
<!-- badges: end -->
You need to extract some specific information from your Rmd or Qmd file?
{lightparser} is designed to split your Rmd or Qmd file by sections into a tibble: titles, text, chunks.
It stores them as a tibble, so you can easily manipulate it with {dplyr} or {purrr}.
Later, you can rebuild a Rmd or Qmd from the tibble.
## Installation
You can install the released CRAN version:
``` r
install.packages("lightparser")
```
You can install the development version of lightparser from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("ThinkR-open/lightparser")
```
## Documentation
Full documentation website on: https://thinkr-open.github.io/lightparser/
## Example
Split your Rmd or Qmd file into a tibble:
```{r, message=FALSE}
library(lightparser)
file <- system.file(
"dev-template-parsing.Rmd",
package = "lightparser"
)
tbl_rmd <- split_to_tbl(file)
tbl_rmd
```
Combine the tibble into a Rmd or Qmd file:
```{r}
file_out <- tempfile(fileext = ".Rmd")
out <- combine_tbl_to_file(tbl_rmd, file_out)
```
Read the file re-created with `combine_tbl_to_file()` to verify it is a proper Rmd
```{r}
cat(readLines(file_out), sep = "\n")
```
## Similar work
{lightparser} is a light version of {parsermd} that has not been updated for a long time,
and which is not compatible with the latest versions of C++ compilers.
{lightparser} does not rely on C++ compilation.
## Code of Conduct
Please note that the lightparser project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.