Remove fill and stroke attributes where their value was black

This commit is contained in:
Brabli
2022-08-14 19:41:31 +01:00
parent 9a95804f3c
commit c75369e0fa
3 changed files with 34 additions and 0 deletions

View File

@@ -80,6 +80,8 @@ final class IconExtension extends AbstractExtension
throw new \TypeError('Size value must be an integer');
$markup = $this->setSize($markup, $options['size']);
$markup = $this->removeBlackStrokeAttributes($markup);
$markup = $this->removeBlackFillAttributes($markup);
return $markup;
}
@@ -153,6 +155,16 @@ final class IconExtension extends AbstractExtension
return $xml;
}
private function removeBlackStrokeAttributes(string $content): string
{
return preg_replace('/stroke="\s*(#0{6}|#000)|(rgb\(\s*0,\s*0,\s*0\s*\))|(black)\s*"/', '', $content);
}
private function removeBlackFillAttributes(string $content): string
{
return preg_replace('/fill="\s*(#0{6}|#000)|(rgb\(\s*0,\s*0,\s*0\s*\))|(black)\s*"/', '', $content);
}
}
class IconNotFound extends \Exception {};