Skip to content

Commit

Permalink
adjust to new release of pillar
Browse files Browse the repository at this point in the history
the color throws off the regex
  • Loading branch information
wibeasley committed Mar 4, 2021
1 parent 6be26d0 commit dd28219
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions R/readr-spec-aligned.R
Expand Up @@ -26,7 +26,8 @@

#' @export
readr_spec_aligned <- function(...) {
pattern <- "^[ ]+`?(.+?)`? = (col_.+)$"
# pattern <- "^[ ]+`?(.+?)`? = .+?(col_.+)\\\\.+$"
pattern <- "^[ ]+`?(.+?)`? = (col_.+).*$"
# pattern <- "^[ ]+(`?)(.+?)\\1 = (col_.+)$"
. <- NULL # This is solely for the sake of avoiding the R CMD check error.

Expand All @@ -36,9 +37,12 @@ readr_spec_aligned <- function(...) {
tibble::enframe(name = NULL) %>%
dplyr::slice(-1, -dplyr::n()) %>%
dplyr::mutate(
# Remove pillar coloring
value = gsub("(\\\033|\\[3\\dm)", "", .data$value),

# Isolate the left-hand & right-hand sides. Enclose all variable names in back ticks.
left = sub(pattern, "`\\1`", .data$value),
right = sub(pattern, "\\2" , .data$value),
left = sub(pattern, "`\\1`", .data$value, perl = TRUE),
right = sub(pattern, "\\2" , .data$value, perl = TRUE),

# Calculate the odd number of spaces -just beyond the longest variable name.
padding = nchar(.data$left),
Expand Down

0 comments on commit dd28219

Please sign in to comment.