assignr
assignr copied to clipboard
removed chunks add extra newlines in -assign.Rmd file
Assignment R Markdown files created with assignr
have one additional newline for each (solution) chunk removed.
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)
}