posit-dev / positron

Positron, a next-generation data science IDE
Other
1.18k stars 32 forks source link

Should `r.rmarkdownRender` command set `html_preview = FALSE`? #3736

Open JosiahParry opened 3 days ago

JosiahParry commented 3 days ago

Positron Version:

Positron Version: 2024.06.1 (Universal) build 27 Code - OSS Version: 1.90.0 Commit: a893e5b282612ccb2200102957ac38d3c14e5196 Date: 2024-06-26T02:08:06.673Z Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.4.0

^ as an aside, consider creating a command prompt to do this for you. Zed does this which makes reporting issues much easier. This is cumbersome and makes me less likely to submit bug reports

Steps to reproduce the issue:

  1. Create an Rmd document
  2. Click the play button select Render document with R Markdown
  3. watch an html file be created

Note that the documentation says:

"When you call rmarkdown::render directly from the command line the preview file is written alongside the generated .md file. However, when you render from within RStudio using the Knit button the preview HTML is written to a temporary directory and then automatically displayed by RStudio."

This does not happen in positron

Source: https://rmarkdown.rstudio.com/github_document_format.html

What did you expect to happen?

Preview file to not be created in my working directory. I do not want to have to modify the yaml front matter to avoid this.

Were there any error messages in the output or Developer Tools console?

juliasilge commented 1 day ago

I may be missing something, but can you explain a bit more in detail about the output front matter vs. rendering in the working directory? I am not understanding the connection.

As a side note, we changed behavior in the Quarto extension in https://github.com/quarto-dev/quarto/pull/435 so that when you preview a file in an R package, the HTML does get written to a temp directory. Can you give me a little more detail on whether you are in an R package or not?

JosiahParry commented 1 day ago

Screen Recording 2024-07-01 at 12 11 19

When you run rmarkdown::render() it creates a preview file which is written to your working directory. This is the default behavior of rmarkdown::render() though I never knew this until using it in positron. When running in RStudio this preview file is written to a temporary directory and previewed:

However, when you render from within RStudio using the Knit button the preview HTML is written to a temporary directory and then automatically displayed by RStudio.

Neither of these things happen in Positron.

My desired experience would be to be able to knit and only the output file is created without a preview html file.

juliasilge commented 1 day ago

OK gotcha, I have updated the title to be more clear what the feature request is here. Right now the r.rmarkdownRender command does use the default behavior of rmarkdown::render(). What I think you are asking for is the equivalent of wanting to do:

rmarkdown::render(output_options = list(html_preview = FALSE))

We could set that in the command itself, or look for a way to have it as an arg.

FWIW, this behavior is exactly as defined for github_document: https://rmarkdown.rstudio.com/docs/reference/github_document.html

It's arguable that we are doing the right thing here.

As a workaround, you can do:

output: 
  github_document:
    html_preview: FALSE