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

Can knitr code blocks preserve blank lines when rendering? #1376

Closed
DavisVaughan opened this issue Jul 1, 2022 · 3 comments · Fixed by #1382
Closed

Can knitr code blocks preserve blank lines when rendering? #1376

DavisVaughan opened this issue Jul 1, 2022 · 3 comments · Fixed by #1382

Comments

@DavisVaughan
Copy link
Member

I'd like to preserve the blank lines in this code block when it gets rendered, is that possible?

#' ```{r}
#' 1 + 1
#'
#' 2 + 2
#' ```

Screen Shot 2022-07-01 at 10 40 29 AM

@remlapmot
Copy link

I think you can get the blank line by setting the collapse knitr chunk option

#' ```{r, collapse=TRUE}
#' 1 + 1
#'
#' 2 + 2
#' ```

There might be a way to do it with the strip.white chunk option as well.

hadley added a commit that referenced this issue Jul 7, 2022
hadley added a commit that referenced this issue Jul 7, 2022
@DavisVaughan
Copy link
Member Author

Yep, collapse = TRUE does work (just confirming, even though Hadley changed it to use this already)

Screen Shot 2022-07-07 at 10 49 49 AM

I'm a bit surprised strip.white = FALSE didn't work, collapse seems like a strange argument name to make this work

Screen Shot 2022-07-07 at 10 50 18 AM

@hadley
Copy link
Member

hadley commented Jul 7, 2022

collapse = TRUE means it makes a single \preformatted{}. The default to create one \preformatted{} per input/ouput runs into the problem in your other issue.

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 a pull request may close this issue.

3 participants