Abhi-1U / texor

Converting 'LaTeX' 'R Journal' Articles into 'RJ-web-articles'
https://abhi-1u.github.io/texor/
Other
7 stars 2 forks source link

Allow relative file paths when setting `input_file` argument of `rnw_to_rmd` #93

Closed hturner closed 2 months ago

hturner commented 2 months ago

The following example only works correctly if the relative file path is first normalized with normalizePath to create an absolute file path:

## copy source files for the {parallel} package vignette to a local folder
article_dir <- "rnw_to_rmd"
dir.create(article_dir)
file.copy(system.file(file.path("doc", "parallel.Rnw"), package = "parallel"),
          file.path(article_dir ,  "parallel.Rnw"))
download.file("https://svn.r-project.org/R/trunk/src/library/parallel/vignettes/parallel.bib",
              file.path(article_dir , "parallel.bib"))

## convert to Rmd
texor::rnw_to_rmd(normalizePath(file.path(article_dir,  "parallel.Rnw")),
  front_matter_type = "vignettes",
  clean_up = TRUE,
  autonumber_eq = TRUE,
  autonumber_sec = TRUE)

It would be more user-freindly if rnw_to_rmd could normalize the path internally, so that relative file paths also work.