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 Oct. 24, 2019, 8:32 p.m.