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 vignettes from grid package (image_filter.lua) #95

Open hturner opened 2 months ago

hturner commented 2 months ago

For example,

sweave_file <- system.file(file.path("doc", "displaylist.Rnw"), package = "grid")

## copy sweave to a local folder
article_dir <- "grid_displaylist"
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)

results in error

Error running filter /Users/stspao/Library/R/arm64/4.4/library/texor/image_filter.lua:
.../Library/R/arm64/4.4/library/texor/image_filter.lua:23: attempt to concatenate a nil value (global 'img_old_src')

I get the same error for "frame.Rnw" - I haven't tried all the grid vignettes!

Abhi-1U commented 2 months ago

The reason it failed is because the image paths (or rather just images) mentioned in the \include_graphics[..]{..} do not exist in the grid_displaylist folder, if we try to compile the displaylist-knitr.Rnw, it creates a figures folder.

Changing the figure path in the \include_graphics[..]{..} to the figure inside the figure folder will allow texor to convert it into Rmd.

The Rmd could not compile due to C memory stack issues in my case.

A possible way to remedy this is during the conversion process, include compilation of the Rnw file as well, so the figures which need to be included are generated.