From 5ee4974370867c8e37933c2d479b70de39c3ce80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Thu, 10 Feb 2022 13:07:29 +0100 Subject: [PATCH] Back out from glue's .literal = TRUE Until we can escape braces better, and we don't break revdeps. --- R/inline.R | 8 ++++---- R/pluralize.R | 2 +- tests/testthat/_snaps/glue.md | 20 -------------------- tests/testthat/test-glue.R | 10 +++++----- 4 files changed, 10 insertions(+), 30 deletions(-) diff --git a/R/inline.R b/R/inline.R index e93e1fc22..d9ef2ac55 100644 --- a/R/inline.R +++ b/R/inline.R @@ -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 @@ -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 = "") @@ -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, "}") } @@ -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), diff --git a/R/pluralize.R b/R/pluralize.R index 916fa6a09..384d57551 100644 --- a/R/pluralize.R +++ b/R/pluralize.R @@ -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) } diff --git a/tests/testthat/_snaps/glue.md b/tests/testthat/_snaps/glue.md index 4409232b9..2144aef3f 100644 --- a/tests/testthat/_snaps/glue.md +++ b/tests/testthat/_snaps/glue.md @@ -5,33 +5,13 @@ Message test_1: all good test_2: not #good - Code - cli::cli_dl(c(test_3 = "no' good either")) - Message - test_3: no' good either - Code - cli::cli_dl(c(test_4 = "no\" good also")) - Message - test_4: no" good also Code cli::cli_text("{.url https://example.com/#section}") Message - Code - cli::cli_alert_success("Qapla'") - Message - v Qapla' # quotes, etc. within expressions are still OK - Code - cli::cli_text("{.url URL} {x <- 'foo'; nchar(x)}") - Message - 3 - Code - cli::cli_text("{.url URL} {x <- \"foo\"; nchar(x)}") - Message - 3 Code cli::cli_text("{.url URL} {1 + 1 # + 1} {1 + 1}") Message diff --git a/tests/testthat/test-glue.R b/tests/testthat/test-glue.R index d8812087e..95b3ce021 100644 --- a/tests/testthat/test-glue.R +++ b/tests/testthat/test-glue.R @@ -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}") }) })