Skip to contents

Group lines of a Rmd or Qmd file by types in a tibble

Usage

split_to_tbl(file)

Arguments

file

A Rmd or Qmd file path

Value

A tibble with 6 columns:

  • type: type of the part (yaml, heading, inline, block)

  • label: label of the part (if any)

  • params: parameters of the part (if any)

  • text: text of the part (if any)

  • code: code of the part (if any)

  • heading: heading of the part (if any)

  • heading_level: level of the heading (if any)

  • section: section of the Rmd file, according to headings (if any)

Examples

file <- system.file(
  "dev-template-parsing.Rmd",
  package = "lightparser"
)
split_to_tbl(file)
#> # A tibble: 35 × 8
#>    type    label       params       text     code  heading heading_level section
#>    <chr>   <chr>       <list>       <named > <lis> <chr>           <dbl> <chr>  
#>  1 yaml    NA          <named list> <lgl>    <lgl> NA                 NA NA     
#>  2 inline  NA          <lgl [1]>    <chr>    <lgl> NA                 NA NA     
#>  3 block   development <named list> <lgl>    <chr> NA                 NA NA     
#>  4 inline  NA          <lgl [1]>    <chr>    <lgl> NA                 NA NA     
#>  5 heading NA          <lgl [1]>    <chr>    <lgl> Descri…             1 Descri…
#>  6 inline  NA          <lgl [1]>    <chr>    <lgl> NA                 NA Descri…
#>  7 block   description <named list> <lgl>    <chr> NA                 NA Descri…
#>  8 inline  NA          <lgl [1]>    <chr>    <lgl> NA                 NA Descri…
#>  9 heading NA          <lgl [1]>    <chr>    <lgl> Read d…             1 Read d…
#> 10 inline  NA          <lgl [1]>    <chr>    <lgl> NA                 NA Read d…
#> # ℹ 25 more rows