Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should specify perl=TRUE in order to handle emoji strings on Windows #157

Merged
merged 2 commits into from
Feb 20, 2020
Merged
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
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ htmltools 0.4.0.9001
* Added `capturePlot` and `plotTag` functions, for easily creating image files
and HTML <img> tags (respectively) from plot expressions.

* Fixed #156: Now `extractPreserveChunks()` handles strings contain Emoji Unicode strings correctly on Windows. (#157)

htmltools 0.4.0
--------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion R/tags.R
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ extractPreserveChunks <- function(strval) {
strval <- paste(strval, collapse = "\n")

# matches contains the index of all the start and end markers
matches <- gregexpr(pattern, strval)[[1]]
matches <- gregexpr(pattern, strval, perl = TRUE)[[1]]
lengths <- attr(matches, "match.length", TRUE)

# No markers? Just return.
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-tags.r
Original file line number Diff line number Diff line change
Expand Up @@ -852,3 +852,12 @@ test_that("trailing commas allowed everywhere", {
css(style = "",)
})
})

test_that("extractPreserveChunks works for emoji strings", {
x <- "<!--html_preserve-->chunck1<!--/html_preserve-->\U0001F937<!--html_preserve-->chunck2<!--/html_preserve-->"
out <- extractPreserveChunks(x)
expect_equivalent(
out$chunks,
c('chunck2', 'chunck1')
)
})