Skip to content

Conversation

@ElianHugh
Copy link
Collaborator

What problem did you solve?

Closes #1403. Smart knitting was failing for multi-line custom knits because the filepath argument was being put on a newline (seemingly due to a linebreak). E.g.

[VSC-R] foo.Rmd process started
==> (function(input, ...) {
  rmarkdown::render(
    input,
    output_file = paste0(
      xfun::sans_ext(input), '-', Sys.Date(), '.html'
    ),
    envir = globalenv()
  )
})
('/run/media/elian/Main/Documents/Coding/R/enumr/foo.Rmd')

Trimming the whitespace from the knit param appears to fix this issue.

How can I check this pull request?

Smart knit a document with the following frontmatter:

---
knit: |
  (function(input, ...) {
    rmarkdown::render(
      input,
      output_file = paste0(
        xfun::sans_ext(input), '-', Sys.Date(), '.html'
      ),
      envir = globalenv()
    )
  })
---

This will succeed with this PR, but will fail otherwise. The output file should be something like foo-2024-02-23.html

Copy link
Member

@renkun-ken renkun-ken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ElianHugh ElianHugh merged commit 26d72d0 into REditorSupport:master Feb 27, 2024
@ElianHugh ElianHugh deleted the multiline-smartknit branch February 27, 2024 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Smart knit fials when a custom function is defined in multiple lines

2 participants