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
- Host: GitHub
- URL: https://github.com/ThinkR-open/lightparser
- Owner: ThinkR-open
- License: other
- Created: 2023-11-16T07:23:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-31T00:28:40.000Z (11 months ago)
- Last Synced: 2024-11-28T21:53:02.177Z (5 months ago)
- Language: R
- Homepage: https://thinkr-open.github.io/lightparser/
- Size: 4.02 MB
- Stars: 23
- Watchers: 4
- Forks: 5
- Open Issues: 7
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- jimsghstars - ThinkR-open/lightparser - From Rmd And Qmd To Tibble And Back (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# lightparser
[](https://github.com/ThinkR-open/lightparser/actions/workflows/R-CMD-check.yaml)
[](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.