From 1e1910db0bb83f5ae91d0aced21669eb52a3fb6c Mon Sep 17 00:00:00 2001 From: eitsupi <50911393+eitsupi@users.noreply.github.com> Date: Wed, 13 Nov 2024 20:41:57 +0900 Subject: [PATCH] fix: replace `knitr:::escape_html` by `xfun::html_escape` (#1284) --- DESCRIPTION | 3 ++- R/pkg-knitr.R | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7983b0c8c..b792236b2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -43,7 +43,8 @@ Suggests: tibble, tools, vctrs, - withr + withr, + xfun (>= 0.48) Config/Needs/website: altdoc, future.apply, diff --git a/R/pkg-knitr.R b/R/pkg-knitr.R index edf385227..95100c89b 100644 --- a/R/pkg-knitr.R +++ b/R/pkg-knitr.R @@ -49,7 +49,13 @@ to_html_table = function(x, max_cols = 75, max_rows = 40) { stop("Please install the `knitr` package to use `to_html_table`.") } - escape_html = getFromNamespace("escape_html", "knitr") + # escape_html will be removed from knitr (> 1.49) + if (exists("html_escape", where = asNamespace("xfun"), mode = "function")) { + escape_html = xfun::html_escape + } else { + escape_html = getFromNamespace("escape_html", "knitr") + } + omit_chr = "…" .dim = dim(x)