Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop the intermediate files *.knit.md and *.utf8.md #2086

Closed
yihui opened this issue Mar 31, 2021 · 5 comments · Fixed by #2098
Closed

Drop the intermediate files *.knit.md and *.utf8.md #2086

yihui opened this issue Mar 31, 2021 · 5 comments · Fixed by #2098
Assignees

Comments

@yihui
Copy link
Member

yihui commented Mar 31, 2021

In rmarkdown, we used to generate the intermediate file *.knit.md from knitr::knit(), and convert it to another intermediate file *.utf8.md. Then pass the utf8 file to Pandoc (because Pandoc only accepts UTF-8 input).

Since knitr 1.24, knitr::knit() only accepts UTF-8 input. Since rmarkdown 2.0, functions in rmarkdown also only accept UTF-8. It makes little sense to generate these two intermediate files now (e.g. d8fbf4c makes an unnecessary file copy), and I suggest that we stop generating them in a future version.

Additional benefits:

  1. blogdown users no longer needs to ignore these files: https://github.com/rstudio/blogdown/blob/a6c92734/R/check.R#L51 It may also avoid the unnecessary refreshing of Hugo server.
  2. bookdown users won't see these intermediate files, either: Terminating build part way through book leaves many intermediate files lying around bookdown#986
@cderv
Copy link
Collaborator

cderv commented Apr 8, 2021

*.knit.md is used for giving a name to the output file after knitting the input.
I would think that we need to keep this intermediates that knitr will write and will be the entry file for Pandoc, and that we need to remove after a render().

For now, I opened a draft PR for some more test by only removing the *.utf8.md

@yihui
Copy link
Member Author

yihui commented Apr 8, 2021

For *.knit.md, I was thinking that we could just use the single extension *.md. This would solve the bookdown issue. However, it will be problematic for blogdown (it's easy to specify that Hugo should ignore *.knit.md, but not easy to ignore *.md since not all *.md files should be ignored).

I guess we can either keep *.knit.md, or add an option to specify the extension (e.g., options(rmarkdown.knit.ext = '.md') can be used for bookdown, and options(rmarkdown.knit.ext = '.md~') for blogdown since Hugo automatically ignores files that end with ~). What do you think?

@cderv
Copy link
Collaborator

cderv commented Apr 8, 2021

I am not quite sure why it will fix the issue for bookdown. Knitting the Rmd will still produce a .md file used for the HTML conversion. This file is not to keep and should be removed (unless keep_md is true).
I find it quit informative to have this file labelle *.knit.md, you know it comes from the knitting process in render. Otherwise, test.Rmd will lead to test.md then test.html.
it is highly possible that a test.md file exist in the working directory already and I am not sure we want to overwrite this one. This is because we render everything in the working dir by default so we need to be careful with filename.

I may have missed why this is an issue for bookdown because the file would still be there but with a different name. Can you (re)explain please?

The options mechanism you suggest would allow to modify behavior for different package.

@yihui
Copy link
Member Author

yihui commented Apr 8, 2021

You are right about bookdown. The intermediate *.md file will still be there. The problem won't be completely solved (with the PR #2098, it only reduces one intermediate file).

Let's keep *.knit.md. If it's easy enough, let's also add a global option for blogdown to customize the intermediate file extension.

@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants