Skip to content

Specific handling for custom writer lua file for R Markdown processing #4347

@cderv

Description

@cderv

Adding figure creation in the test qmd file, we can see that the the figure dir is in another folder containing format in the name

And so now I have it all covered. Probably another issue but related.

The directory with format in the name is created by rmarkdown when R chunks are added. I don't think Quarto expect this so not sure we are cleaning this correctly.

When no output_file is passed to rmarkdown::render(), one is automatically determined considering the pandoc.to format.

# determine the output file for a pandoc conversion
pandoc_output_file <- function(input, pandoc_options) {
  to <- strsplit(pandoc_options$to, "[+-]")[[1]][[1]]
  ext <- pandoc_output_ext(pandoc_options$ext, to, input)
  output <- paste0(xfun::sans_ext(input), ext)
  basename(output)
}

With to being customwriter.lua, the output file will have a .customwriter suffix as we can see in above comments

Then the files where to store figures for knitr is computed based on output_file

files_dir_slash <- file.path(output_dir, knitr_files_dir(basename(output_file)))

which will lead to the other folder customwriter-yaml.customformat_files when R code are into this.

I believe this will happen with any format no known by rmarkdown function pandoc_output_ext

pandoc_output_ext <- function(ext, to, input) {
  if (!is.null(ext)) return(ext)
  if (to %in% c("latex", "beamer")) return(".pdf")
  if (to %in% c("html", "html4", "html5", "s5", "slidy", "slideous", "dzslides", "revealjs"))
    return(".html")
  if (to == "markdown" && tolower(xfun::file_ext(input)) != "md") return(".md")
  paste0(".", to)
}

I'll probably look into that in another issue too, but that explains the behavior and differences seen above

Originally posted by @cderv in #4260 (comment)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions