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

`rnw_to_rmd()` fails on Sweave vignette from utils package #96

Open hturner opened 2 months ago

hturner commented 2 months ago
sweave_file <- system.file(file.path("doc", "Sweave.Rnw"), package = "utils")

## copy sweave to a local folder
article_dir <- "utils_Sweave"
dir.create(article_dir)
file.copy(sweave_file, article_dir)

## convert to Rmd (N.B. must be full path not relative path to work)
texor::rnw_to_rmd(normalizePath(file.path(article_dir,  basename(sweave_file))),
  front_matter_type = "vignettes",
  clean_up = TRUE,
  autonumber_eq = TRUE,
  autonumber_sec = TRUE)

gives the warning and error:

Warning message:
In rnw_generate_rmd(dir, web_dir = web_dir, interactive_mode = interactive_mode,  :
  Pandoc Failed to convert the LaTeX article, please check for missing brackets/closing environments and spelling mistakes !
Error in `replace_all_sec_ref()`:
! File does not exist

It would be nice to have this working, since it is the vignette for Sweave itself, though it may be a complex example (15 pages!).

Abhi-1U commented 1 month ago

This one is unique, as the author tries to portray the Sweave syntax in the verbatim environment, for example \verb|<<figN, fig=TRUE, pdf=FALSE, png=TRUE>>| . Now, the Lua Reader will match this as a start of sweave code block and will match the next @ at the end of another sweave code chunk as the end of the sweave code block and capture everything in between, hence the remaining LaTeX code becomes incomplete and conversion fails.