Skip to content

Commit

Permalink
test: add test for markdown_text()'s handling of ANSI characters
Browse files Browse the repository at this point in the history
  • Loading branch information
maelle committed Oct 4, 2024
1 parent 75d8ec2 commit 022306c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/testthat/_snaps/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@
Error in `config_math_rendering_()`:
! In _pkgdown.yml, template.math-rendering must be one of mathml, mathjax, and katex, not math.

# preserves ANSI characters

Code
markdown_text(pkg, sprintf("prefer %s", cli::col_blue("a")))
Output
{html_document}
<html>
[1] <body><p>prefer \u2029[34ma\u2029[39m</p></body>

8 changes: 8 additions & 0 deletions tests/testthat/test-markdown.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ test_that("validates math yaml", {
config_math_rendering_(`math-rendering` = "math")
})
})

test_that("preserves ANSI characters", {
withr::local_options(cli.num_colors = 256)
pkg <- local_pkgdown_site()
expect_snapshot(
markdown_text(pkg, sprintf("prefer %s", cli::col_blue("a")))
)
})

0 comments on commit 022306c

Please sign in to comment.