-
Notifications
You must be signed in to change notification settings - Fork 126
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
Generate a PDF with Chrome using the Knit button of RStudio IDE #155
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of introducing a new function, I'd like make chrome_print
work for the Knit button. We need to add the encoding
argument to it (and ignore it). Then the only tricky thing is determine whether chrome_print
is called by RStudio when the user clicks the Knit button. I think this should be sufficient:
is_rstudio_knit = !interactive() && !is.na(Sys.getenv('RSTUDIO', NA)) && !missing(encoding)
If you want to be more strict, you can add another condition length(match.call()) == 3
(to make sure only two arguments are passed to the function).
Then we call rmarkdown::render(..., quiet = is_rstudio_knit)
to suppress the message, and emit the message('\nOutput create: ...')
by ourselves.
Does this proposal sound good?
Of course... because I had already thought about that 😄 |
I already tried |
I wonder what happens if you don't change the |
I've already tested it 😉 and RStudio IDE opens the file in the first message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! Thank you!
Here's a proposal to create a custom render function for the RStudio IDE.
My main problem is to give a name for this new function 😃 (that's why I open a PR).
In short, by adding
knit: pagedown::knit_pdf_chrome
in the YAML header, a PDF is also generated by clicking on the "Knit" button of RStudio.I don't like very much the current name
knit_pdf_chrome
but I have no better idea. I'd appreciate any proposal.This PR also enhances the documentation about printing to PDF.