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

https://github.com/ThinkR-open/lightparser

From Rmd And Qmd To Tibble And Back
https://github.com/ThinkR-open/lightparser

Last synced: 4 months ago
JSON representation

From Rmd And Qmd To Tibble And Back

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%"
)
```

# lightparser

[![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)

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.