Thanks to visit codestin.com
Credit goes to github.com

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
19 changes: 13 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ License: BSD_3_clause + file LICENSE
LazyData: TRUE
Depends: R (>= 3.3)
Imports:
Rcpp (>= 0.12.2), stringi, RcppParallel,
htmlwidgets (>= 0.6),
LinkingTo: Rcpp, RcppParallel
Rcpp (>= 0.12.2),
stringi,
RcppParallel
LinkingTo:
Rcpp,
RcppParallel
Suggests:
knitr (>= 1.12.3),testthat,
rmarkdown (>= 0.9.5),microbenchmark,
ggplot2, directlabels
htmlwidgets (>= 0.6),
knitr (>= 1.12.3),
testthat,
rmarkdown (>= 0.9.5),
microbenchmark,
ggplot2,
directlabels
URL: https://github.com/qinwf/re2r/
BugReports: https://github.com/qinwf/re2r/issues
VignetteBuilder: knitr
Expand Down
10 changes: 7 additions & 3 deletions R/widget.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ remove_named = function(string){
#' @export
show_regex <- function(pattern, width = NULL, height = NULL) {

if (is.character(pattern)){
if (!requireNamespace("htmlwidgets", quietly = TRUE)) {
stop("'htmlwidgets' package is not installed.")
}

if (is.character(pattern)) {
res = re2(pattern)
}else if (inherits(pattern,"re2c")) {
} else if (inherits(pattern,"re2c")) {
res = pattern
} else if (is.list(pattern)){
} else if (is.list(pattern)) {
return(show_regex(pattern[[1]], width, height))
} else {
stop("pattern is a string or a pre-compiled regular expression.")
Expand Down
1 change: 0 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

##' @useDynLib re2r
##' @import Rcpp
##' @import htmlwidgets
##' @importFrom stringi stri_enc_toutf8
##' @importFrom RcppParallel RcppParallelLibs
NULL
1 change: 1 addition & 0 deletions tests/testthat/test-show.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
context("test show regex")

test_that("test show_regex",{
skip_if_not_installed("htmlwidgets")
show_regex(re2("(?P<testname>>this)( is)(?P<testname>>this)"))
show_regex("show_regex")
expect_error(show_regex(list()))
Expand Down