R/remove_zero_padding.R

Defines functions remove_zero_padding

Documented in remove_zero_padding

#' Removes noop padding from an RTF markup
#'
#' @details
#' Removes noop padding, which is padding that has a thickness of zero
#' from an RTF markup.
#'
#' @param rtf `character(1)` RTF markup
#'
#' @return `character(1)` RTF markup with removed zero padding
#' @keywords internal
remove_zero_padding <- function(rtf) {
  noop_padding <- function(direction) {
    sprintf(r"{\\clpadf%s3\\clpad%s0 }", direction, direction)
  }
  for (direction in c("l", "r", "b", "t")) {
    rtf <- stringr::str_replace_all(rtf, noop_padding(direction), "")
  }
  rtf
}

Try the tidytlg package in your browser

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

tidytlg documentation built on June 22, 2024, 10:43 a.m.