assignr icon indicating copy to clipboard operation
assignr copied to clipboard

removed chunks add extra newlines in -assign.Rmd file

Open daviddalpiaz opened this issue 3 years ago • 1 comments

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

daviddalpiaz avatar Jan 14 '22 02:01 daviddalpiaz

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)
}

daviddalpiaz avatar Jan 16 '22 18:01 daviddalpiaz