diff --git a/lib/Alchemy/Phrasea/Core/Provider/TwigServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/TwigServiceProvider.php
index 6b9ceae618..4dddd878ad 100644
--- a/lib/Alchemy/Phrasea/Core/Provider/TwigServiceProvider.php
+++ b/lib/Alchemy/Phrasea/Core/Provider/TwigServiceProvider.php
@@ -127,6 +127,22 @@ class TwigServiceProvider implements ServiceProviderInterface
);
}, ['needs_environment' => true, 'is_safe' => ['html']]));
+ $twig->addFilter(new \Twig_SimpleFilter('parseColor', function (\Twig_Environment $twig, $string) use ($app) {
+ $re = '/^(.*)\[#([0-9a-fA-F]{6})]$/m';
+ $stringArr = explode(';', $string);
+ foreach ($stringArr as $key => $value) {
+ preg_match_all($re, trim($value), $matches);
+ if ($matches && $matches[1] != null && $matches[2] != null) {
+ $colorCode = '#' . $matches[2][0];
+ $colorName = $matches[1][0];
+
+ $stringArr[$key] = '' . $colorName . '
';
+ }
+ }
+
+ return implode('', $stringArr);
+ }, ['needs_environment' => true, 'is_safe' => ['html']]));
+
$twig->addFilter(new \Twig_SimpleFilter('bounce',
function (\Twig_Environment $twig, $fieldValue, $fieldName, $searchRequest, $sbasId) {
// bounce value if it is present in thesaurus as well
diff --git a/templates/web/common/macros.html.twig b/templates/web/common/macros.html.twig
index 50091a8af3..1683aa98c3 100644
--- a/templates/web/common/macros.html.twig
+++ b/templates/web/common/macros.html.twig
@@ -128,8 +128,8 @@