R/lines.R

Defines functions simplify_paragraphs

Documented in simplify_paragraphs

#' Eliminate within-paragraph line breaks

#' @export
simplify_paragraphs <- function(text) {
  tmp <- gsub("\n{2,}", " special code ", text)
  tmp <- gsub("\n", " ", tmp)
  tmp <- gsub(" special code ", "\n\n", tmp)
  # smart quotes
  tmp <- gsub("(``[^`]\\{r|'')", "\"", tmp)

  tmp
}
dtkaplan/detex documentation built on July 6, 2017, 8:12 p.m.