diff --git a/R/highlight.r b/R/highlight.r index afc2f73b6..0026ff662 100644 --- a/R/highlight.r +++ b/R/highlight.r @@ -10,8 +10,8 @@ highlight_text <- function(text) { error = function(e) NULL ) - # Failed to parse - if (is.null(expr)) { + # Failed to parse, or yielded empty expression + if (length(expr) == 0) { return(escape_html(text)) } diff --git a/tests/testthat/test-highlight.R b/tests/testthat/test-highlight.R index ad7f8b0dc..342778d95 100644 --- a/tests/testthat/test-highlight.R +++ b/tests/testthat/test-highlight.R @@ -59,9 +59,3 @@ test_that("unparsed code is still escaped", { expect_equal(highlight_text("<"), "<") }) -test_that("code consisting of comments only is not stripped of tags", { - scoped_package_context("test") - - expect_equal(highlight_text("#"), "#") -}) -