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

removed chunks add extra newlines in -assign.Rmd file #18

Open
daviddalpiaz opened this issue Jan 14, 2022 · 1 comment
Open

removed chunks add extra newlines in -assign.Rmd file #18

daviddalpiaz opened this issue Jan 14, 2022 · 1 comment

Comments

@daviddalpiaz
Copy link
Contributor

Assignment R Markdown files created with assignr have one additional newline for each (solution) chunk removed.

@daviddalpiaz
Copy link
Contributor Author

I'm currently running the following on the -assign.Rmd files as a part of my build process for a course:

remove_extra_newlines = function(file) {
  input = readLines(file)
  output = which(input == "")
  output = input[-(output[which((output + 1)[-length(output)] == output[-1])])]
  output = output[-length(output)]
  writeLines(text = output, con = file)
}

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

No branches or pull requests

1 participant