Skip to content

Commit

Permalink
Back out from glue's .literal = TRUE
Browse files Browse the repository at this point in the history
Until we can escape braces better, and we don't break
revdeps.
  • Loading branch information
gaborcsardi committed Feb 10, 2022
1 parent 6a8c530 commit 5ee4974
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 30 deletions.
8 changes: 4 additions & 4 deletions R/inline.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 137,7 @@ inline_transformer <- function(code, envir) {
.open = paste0("{", envir$marker),
.close = paste0(envir$marker, "}"),
.trim = TRUE,
.literal = TRUE
.comment = ""
)

# If we don't have a brace expression, then (non-inherited) styling was
Expand Down Expand Up @@ -218,7 218,7 @@ clii__inline <- function(app, text, .list) {
.open = paste0("{", t$values$marker),
.close = paste0(t$values$marker, "}"),
.trim = TRUE,
.literal = TRUE
.comment = ""
)
})
paste(out, collapse = "")
Expand Down Expand Up @@ -269,7 269,7 @@ make_cmd_transformer <- function(values) {
.envir = envir,
.transformer = sys.function(),
.trim = TRUE,
.literal = TRUE
.comment = ""
)
paste0("{", values$marker, ".", funname, " ", out, values$marker, "}")
}
Expand All @@ -285,7 285,7 @@ glue_cmd <- function(..., .envir) {
.envir = .envir,
.transformer = transformer,
.trim = TRUE,
.literal = TRUE
.comment = ""
)
glue_delay(
str = post_process_plurals(pstr, values),
Expand Down
2 changes: 1 addition & 1 deletion R/pluralize.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 183,6 @@ pluralize <- function(..., .envir = parent.frame(),
}
}

raw <- glue::glue(..., .envir = .envir, .transformer = tf, .literal = TRUE)
raw <- glue::glue(..., .envir = .envir, .transformer = tf, .comment = "")
post_process_plurals(raw, values)
}
20 changes: 0 additions & 20 deletions tests/testthat/_snaps/glue.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 5,13 @@
Message <cliMessage>
test_1: all good
test_2: not #good
Code
cli::cli_dl(c(test_3 = "no' good either"))
Message <cliMessage>
test_3: no' good either
Code
cli::cli_dl(c(test_4 = "no\" good also"))
Message <cliMessage>
test_4: no" good also
Code
cli::cli_text("{.url https://example.com/#section}")
Message <cliMessage>
<https://example.com/#section>
Code
cli::cli_alert_success("Qapla'")
Message <cliMessage>
v Qapla'

# quotes, etc. within expressions are still OK

Code
cli::cli_text("{.url URL} {x <- 'foo'; nchar(x)}")
Message <cliMessage>
<URL> 3
Code
cli::cli_text("{.url URL} {x <- \"foo\"; nchar(x)}")
Message <cliMessage>
<URL> 3
Code
cli::cli_text("{.url URL} {1 1 # 1} {1 1}")
Message <cliMessage>
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-glue.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 9,17 @@ test_that("glue quotes and comments", {
"test_2" = "not #good"
)
)
cli::cli_dl(c("test_3" = "no' good either"))
cli::cli_dl(c("test_4" = "no\" good also"))
# cli::cli_dl(c("test_3" = "no' good either"))
# cli::cli_dl(c("test_4" = "no\" good also"))
cli::cli_text("{.url https://example.com/#section}")
cli::cli_alert_success("Qapla'")
# cli::cli_alert_success("Qapla'")
})
})

test_that("quotes, etc. within expressions are still OK", {
expect_snapshot({
cli::cli_text("{.url URL} {x <- 'foo'; nchar(x)}")
cli::cli_text("{.url URL} {x <- \"foo\"; nchar(x)}")
# cli::cli_text("{.url URL} {x <- 'foo'; nchar(x)}")
# cli::cli_text("{.url URL} {x <- \"foo\"; nchar(x)}")
cli::cli_text("{.url URL} {1 1 # 1} {1 1}")
})
})

0 comments on commit 5ee4974

Please sign in to comment.