From bdb8821a11f2fb07402c5d05055c6eae91244529 Mon Sep 17 00:00:00 2001 From: RedLucas Date: Mon, 10 Jul 2017 17:12:53 -0700 Subject: [PATCH] Make the clean_class filter act like Drupal one. I would feel more comfortable using the clean_class filter in my pattern-lab templates if I was confident it would do the same in Pattern Lab as it does in Drupal. --- dist/filters/clean_class.filter.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dist/filters/clean_class.filter.php b/dist/filters/clean_class.filter.php index 7dcda24..3f0f83b 100755 --- a/dist/filters/clean_class.filter.php +++ b/dist/filters/clean_class.filter.php @@ -1,5 +1,18 @@ '-', + '_' => '-', + '/' => '-', + '[' => '-', + ']' => '', + ]; + $string = str_replace(array_keys($filters), array_values($filters), $string); + $string = preg_replace('/[^\x{002D}\x{0030}-\x{0039}\x{0041}-\x{005A}\x{005F}\x{0061}-\x{007A}\x{00A1}-\x{FFFF}]/u', '', $string); + $string = preg_replace([ + '/^[0-9]/', + '/^(-[0-9])|^(--)/' + ], ['_', '__'], $string); return $string; });