Explorar el Código

Add padding to results group when many groups

tags/v0.1.0^2
Garrick Aden-Buie hace 8 años
padre
commit
c06337a8b4
Se han modificado 2 ficheros con 12 adiciones y 2 borrados
  1. +12
    -1
      R/run_regex.R
  2. +0
    -1
      inst/style.css

+ 12
- 1
R/run_regex.R Ver fichero

@@ -130,7 +130,18 @@ view_regex <- function(
}
res <- run_regex(text, pattern, ...)
res <- purrr::map_chr(res, wrap_result, escape = escape)
res <- paste("<p class='results'>", res, "</p>")
res <- purrr::map_chr(res, function(resi) {
result_pad <- ""
if (grepl("pad\\d{2}", resi)) {
max_pad <- max(stringr::str_extract_all(resi, "pad\\d{2}")[[1]])
max_pad_level <- as.integer(stringr::str_extract(max_pad, "\\d{2}"))
if (max_pad_level - 3 > 0) {
result_pad <- sprintf("pad%02d", max_pad_level - 3)
}
}
paste("<p class='results", result_pad, "'>", resi, "</p>")
})
res <- paste(res, collapse = "")
if (!nchar(pattern)) res <- paste("<p class='results'>", text, "</p>")
if (knitr) return(knitr::asis_output(res))
if (!render) return(res)

+ 0
- 1
inst/style.css Ver fichero

@@ -1,6 +1,5 @@
.results {
font-family: "Monaco", "Inconsolata", monospace;
padding-top: 5px;
}

.gadget-result {

Cargando…
Cancelar
Guardar