R/combine_lines.R

Defines functions combine_lines

combine_lines <- function(lines) {
  # If a brace is followed by a newline and a % we can proceed
  lines[endsWith(shift(lines, fill = ""), "}") & startsWith(lines, "%")] <- " "
  lines[endsWith(shift(lines, n = 2L, fill = ""), "}") & startsWith(lines, "%")] <- " "
  
  oneline <- paste0(lines, collapse = "NEW.")
  out <- strsplit(oneline, split = "NEW.NEW.NEW.", fixed = TRUE)[[1]]
  out <- gsub("NEW.", "", out, fixed = TRUE)
  out
}

Try the TeXCheckR package in your browser

Any scripts or data that you put into this service are public.

TeXCheckR documentation built on Nov. 17, 2020, 9:08 a.m.