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

Fix multiline smart-knit #1493

Merged
merged 1 commit into from
Feb 27, 2024

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
6 of 8 checks passed
@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