Skip to content

Commit e28e552

Browse files
committed
Minor cleanup
1 parent b69921b commit e28e552

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

R/parser.R

+12-13
Original file line numberDiff line numberDiff line change
@@ -339,16 +339,15 @@ CombinedSelector <- R6Class("CombinedSelector",
339339
#### Parser
340340

341341
# foo
342-
el_re <- '^[ \t\r\n\f]*([a-zA-Z]+)[ \t\r\n\f]*$'
342+
el_re <- "^[ \t\r\n\f]*([a-zA-Z]+)[ \t\r\n\f]*$"
343343

344344
# foo#bar or #bar
345-
id_re <- '^[ \t\r\n\f]*([a-zA-Z]*)#([a-zA-Z0-9_-]+)[ \t\r\n\f]*$'
345+
id_re <- "^[ \t\r\n\f]*([a-zA-Z]*)#([a-zA-Z0-9_-]+)[ \t\r\n\f]*$"
346346

347347
# foo.bar or .bar
348-
class_re <- '^[ \t\r\n\f]*([a-zA-Z]*)\\.([a-zA-Z][a-zA-Z0-9_-]*)[ \t\r\n\f]*$'
348+
class_re <- "^[ \t\r\n\f]*([a-zA-Z]*)\\.([a-zA-Z][a-zA-Z0-9_-]*)[ \t\r\n\f]*$"
349349

350350
parse <- function(css) {
351-
nc <- nchar(css)
352351
el_match <- str_match(css, el_re)[1, 2]
353352
if (!is.na(el_match))
354353
return(list(Selector$new(Element$new(element = el_match))))
@@ -430,7 +429,7 @@ parse_selector <- function(stream) {
430429
} else {
431430
# By exclusion, the last parse_simple_selector() ended
432431
# at peek == ' '
433-
combinator <- ' '
432+
combinator <- " "
434433
}
435434
stuff <- parse_simple_selector(stream)
436435
pseudo_element <- stuff$pseudo_element
@@ -537,7 +536,7 @@ parse_simple_selector <- function(stream, inside_negation = FALSE) {
537536
while (TRUE) {
538537
nt <- stream$nxt()
539538
if (nt$type %in% c("IDENT", "STRING", "NUMBER") ||
540-
(token_equality(nt ,"DELIM", "+") ||
539+
(token_equality(nt, "DELIM", "+") ||
541540
token_equality(nt, "DELIM", "-"))) {
542541
arguments[[i]] <- nt
543542
i <- i + 1
@@ -663,7 +662,7 @@ parse_series <- function(tokens) {
663662
return(c(0, result))
664663
}
665664
}
666-
ab <- str_split_fixed(s, "n", 2)[1,]
665+
ab <- str_split_fixed(s, "n", 2)[1, ]
667666
a <- str_trim(ab[1])
668667
b <- str_trim(ab[2])
669668

@@ -726,20 +725,20 @@ compile_ <- function(pattern) {
726725
}
727726
}
728727

729-
delims_2ch <- c('~=', '|=', '^=', '$=', '*=', '::', '!=')
730-
delims_1ch <- c('>', '+', '~', ',', '.', '*', '=', '[', ']', '(', ')', '|', ':', '#')
728+
delims_2ch <- c("~=", "|=", "^=", "$=", "*=", "::", "!=")
729+
delims_1ch <- c(">", "+", "~", ",", ".", "*", "=", "[", "]", "(", ")", "|", ":", "#")
731730
delim_escapes <- paste0("\\", delims_1ch, collapse = "|")
732-
match_whitespace <- compile_('[ \t\r\n\f]+')
733-
match_number <- compile_('[+-]?(?:[0-9]*\\.[0-9]+|[0-9]+)')
731+
match_whitespace <- compile_("[ \t\r\n\f]+")
732+
match_number <- compile_("[+-]?(?:[0-9]*\\.[0-9]+|[0-9]+)")
734733
match_hash <- compile_(paste0("^#([_a-zA-Z0-9-]|", nonascii, "|\\\\(?:", delim_escapes, "))+"))
735734
match_ident <- compile_(paste0("^([_a-zA-Z0-9-]|", nonascii, "|\\\\(?:", delim_escapes, "))+"))
736735
match_string_by_quote <- list("'" = compile_(paste0("([^\n\r\f\\']|", TokenMacros$string_escape, ")*")),
737736
'"' = compile_(paste0('([^\n\r\f\\"]|', TokenMacros$string_escape, ")*")))
738737

739738
# Substitution for escaped chars
740-
sub_simple_escape <- function(x) gsub('\\\\(.)', "\\1", x)
739+
sub_simple_escape <- function(x) gsub("\\\\(.)", "\\1", x)
741740
sub_unicode_escape <- function(x) gsub(TokenMacros$unicode_escape, "\\1", x, ignore.case = TRUE)
742-
sub_newline_escape <- function(x) gsub('\\\\(?:\n|\r\n|\r|\f)', "", x)
741+
sub_newline_escape <- function(x) gsub("\\\\(?:\n|\r\n|\r|\f)", "", x)
743742

744743
tokenize <- function(s) {
745744
pos <- 1

R/xpath.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ GenericTranslator <- R6Class("GenericTranslator",
422422
# for a == 1, nth-*(an+b) means n+b-1 siblings before/after,
423423
# and since n %in% {0, 1, 2, ...}, if b-1<=0,
424424
# there is always an "n" matching any number of siblings (maybe none)
425-
if (a == 1 && b_min_1 <=0) {
425+
if (a == 1 && b_min_1 <= 0) {
426426
return(xpath)
427427
}
428428
# early-exit condition 2:

0 commit comments

Comments
 (0)