Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* New `{.num}` and `{.bytes}` inline styles to format numbers
and bytes (@m-muecke, #644, #588, #643).

* Fix escaping of `<>` so that `cli_bullets_raw()` doesn't attempt to
perform string interpolation on them (@mcol, #789).

# cli 3.6.5

* `code_highlight()` supports long strings and symbols
Expand Down
2 changes: 2 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ has_packages <- function(pkgs) {
cli_escape <- function(x) {
x <- gsub("{", "{{", x, fixed = TRUE)
x <- gsub("}", "}}", x, fixed = TRUE)
x <- gsub("<", "<<", x, fixed = TRUE)
x <- gsub(">", ">>", x, fixed = TRUE)
x
}

Expand Down
96 changes: 96 additions & 0 deletions tests/testthat/_snaps/bullets.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,99 @@
→ This is some text that is longer than the width. This is some text that is
longer than the width. This is some text that is longer than the width.

# bullets_raw glue [plain]

Code
cli_bullets_raw(c("noindent {.key {1:3}}", ` ` = "space {.key {1:3}}", v = "success {.key {1:3}}",
x = "danger {.key {1:3}}", `!` = "warning {.key {1:3}}", i = "info {.key {1:3}}",
`*` = "bullet {.key {1:3}}", `>` = "arrow {.key {1:3}}"))
Message
noindent {{.key {{1:3}}}}
space {{.key {{1:3}}}}
v success {{.key {{1:3}}}}
x danger {{.key {{1:3}}}}
! warning {{.key {{1:3}}}}
i info {{.key {{1:3}}}}
* bullet {{.key {{1:3}}}}
> arrow {{.key {{1:3}}}}

# bullets_raw glue [ansi]

Code
cli_bullets_raw(c("noindent {.key {1:3}}", ` ` = "space {.key {1:3}}", v = "success {.key {1:3}}",
x = "danger {.key {1:3}}", `!` = "warning {.key {1:3}}", i = "info {.key {1:3}}",
`*` = "bullet {.key {1:3}}", `>` = "arrow {.key {1:3}}"))
Message
noindent {{.key {{1:3}}}}
space {{.key {{1:3}}}}
v success {{.key {{1:3}}}}
x danger {{.key {{1:3}}}}
! warning {{.key {{1:3}}}}
i info {{.key {{1:3}}}}
* bullet {{.key {{1:3}}}}
> arrow {{.key {{1:3}}}}

# bullets_raw glue [unicode]

Code
cli_bullets_raw(c("noindent {.key {1:3}}", ` ` = "space {.key {1:3}}", v = "success {.key {1:3}}",
x = "danger {.key {1:3}}", `!` = "warning {.key {1:3}}", i = "info {.key {1:3}}",
`*` = "bullet {.key {1:3}}", `>` = "arrow {.key {1:3}}"))
Message
noindent {{.key {{1:3}}}}
space {{.key {{1:3}}}}
✔ success {{.key {{1:3}}}}
✖ danger {{.key {{1:3}}}}
! warning {{.key {{1:3}}}}
ℹ info {{.key {{1:3}}}}
• bullet {{.key {{1:3}}}}
→ arrow {{.key {{1:3}}}}

# bullets_raw glue [fancy]

Code
cli_bullets_raw(c("noindent {.key {1:3}}", ` ` = "space {.key {1:3}}", v = "success {.key {1:3}}",
x = "danger {.key {1:3}}", `!` = "warning {.key {1:3}}", i = "info {.key {1:3}}",
`*` = "bullet {.key {1:3}}", `>` = "arrow {.key {1:3}}"))
Message
noindent {{.key {{1:3}}}}
space {{.key {{1:3}}}}
✔ success {{.key {{1:3}}}}
✖ danger {{.key {{1:3}}}}
! warning {{.key {{1:3}}}}
ℹ info {{.key {{1:3}}}}
• bullet {{.key {{1:3}}}}
→ arrow {{.key {{1:3}}}}

# bullets_raw handles <> (#789) [plain]

Code
cli_bullets_raw(c("{.field field} <x>", "{.field field} <<x>>"))
Message
{{.field field}} <x>
{{.field field}} <<x>>

# bullets_raw handles <> (#789) [ansi]

Code
cli_bullets_raw(c("{.field field} <x>", "{.field field} <<x>>"))
Message
{{.field field}} <x>
{{.field field}} <<x>>

# bullets_raw handles <> (#789) [unicode]

Code
cli_bullets_raw(c("{.field field} <x>", "{.field field} <<x>>"))
Message
{{.field field}} <x>
{{.field field}} <<x>>

# bullets_raw handles <> (#789) [fancy]

Code
cli_bullets_raw(c("{.field field} <x>", "{.field field} <<x>>"))
Message
{{.field field}} <x>
{{.field field}} <<x>>

20 changes: 20 additions & 0 deletions tests/testthat/test-bullets.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,23 @@ test_that_cli("bullets wrapping", {
">" = txt
)))
})

test_that_cli("bullets_raw glue", {
expect_snapshot(cli_bullets_raw(c(
"noindent {.key {1:3}}",
" " = "space {.key {1:3}}",
"v" = "success {.key {1:3}}",
"x" = "danger {.key {1:3}}",
"!" = "warning {.key {1:3}}",
"i" = "info {.key {1:3}}",
"*" = "bullet {.key {1:3}}",
">" = "arrow {.key {1:3}}"
)))
})

test_that_cli("bullets_raw handles <> (#789)", {
expect_snapshot(cli_bullets_raw(c(
"{.field field} <x>",
"{.field field} <<x>>"
)))
})
Loading