From 7ede95b4c0a37a6cfabc54607c2b0829ae16bb84 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 7 Jun 2024 10:21:30 +0200 Subject: [PATCH] less naive regex --- R/guide_marquee.R | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/R/guide_marquee.R b/R/guide_marquee.R index 8c75e7b..274ac15 100644 --- a/R/guide_marquee.R +++ b/R/guide_marquee.R @@ -92,11 +92,6 @@ #' base + aes(colour = class) + #' labs(colour = "Cars including suv and minivan vehicles") + #' guides(colour = guide_marquee(detect = TRUE)) -#' -#' # Automatic detection is not always a good idea -#' base + -#' labs(colour = "Kerfuffles 4 the riffraff from frankfurt") + -#' guides(colour = guide_marquee(detect = TRUE)) guide_marquee <- function(title = ggplot2::waiver(), # Note: prefixing namespace prevents recursive default argument style = marquee::style(background = NA), @@ -319,10 +314,12 @@ replace_tags <- function(text, labels, detect) { } if (isTRUE(detect)) { - # TODO: this is really naive and might match glyphs and tags - labels <- regescape(labels) + # Regex pattern searches for labels flanked by word breaks \b(label)\b and + # excludes matches within tags (?