diff --git a/lib/tagger.php b/lib/tagger.php index eff5809bc..c5948c392 100644 --- a/lib/tagger.php +++ b/lib/tagger.php @@ -646,12 +646,20 @@ function is_style($tag, $match = self::STYLE_FG_BG) { } /** @return string */ - function color_regex() { + private function color_regex() { if (!$this->color_re) { - $re = "{(?:\\A| )(?:\\d*~|~~|)(" . join("|", array_keys($this->style_info_lmap)); - foreach ($this->filter("colors") as $t) - $re .= "|" . $t->tag_regex(); - $this->color_re = $re . ")(?=\\z|[# ])}i"; + $re = "{(?:\\A| )(?:(?:\\d*~|~~|)(" . join("|", array_keys($this->style_info_lmap)); + $any = false; + foreach ($this->filter("colors") as $t) { + if (!$any) { + $re .= ")|("; + $any = true; + } else { + $re .= "|"; + } + $re .= $t->tag_regex(); + } + $this->color_re = $re . "))(?=\\z|[# ])}i"; } return $this->color_re; } @@ -663,13 +671,13 @@ function styles($tags, $match = 0, $no_pattern_fill = false) { } if (!$tags || $tags === " " - || !preg_match_all($this->color_regex(), $tags, $m)) { + || !preg_match_all($this->color_regex(), $tags, $ms, PREG_SET_ORDER)) { return null; } $classes = []; $info = 0; - foreach ($m[1] as $tag) { - $ltag = strtolower($tag); + foreach ($ms as $m) { + $ltag = strtolower($m[1] ? : $m[2]); $t = $this->check($ltag); $ks = $t ? $t->colors : [$ltag]; foreach ($ks as $k) { diff --git a/src/settings/s_tags.php b/src/settings/s_tags.php index 344b10a33..b804ff889 100644 --- a/src/settings/s_tags.php +++ b/src/settings/s_tags.php @@ -161,7 +161,7 @@ function parse(SettingValues $sv, Si $si) { $ts = array(); foreach ($sv->conf->tags()->canonical_colors() as $k) { if ($sv->has_reqv("tag_color_$k")) { - foreach ($this->my_parse_list($sv->si("tag_color_$k"), Tagger::NOPRIVATE | Tagger::NOCHAIR | Tagger::NOVALUE | Tagger::ALLOWSTAR, false) as $t) { + foreach ($this->my_parse_list($sv->si("tag_color_$k"), Tagger::NOPRIVATE | Tagger::NOVALUE | Tagger::ALLOWSTAR, false) as $t) { $ts[] = $t . "=" . $k; } }