From 83ef15b8282fa701d32f2838a7ced4a782ed02f2 Mon Sep 17 00:00:00 2001 From: Matthieu Bizien Date: Tue, 14 Jan 2025 22:34:33 +0100 Subject: [PATCH] chore: char limits --- tinycss2/serializer.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tinycss2/serializer.py b/tinycss2/serializer.py index 9a69502..56639db 100644 --- a/tinycss2/serializer.py +++ b/tinycss2/serializer.py @@ -76,11 +76,12 @@ def serialize_name(value): "\r": r"\D ", "\f": r"\C ", } -_re_string_value = re.compile("["+"".join(re.escape(e) for e in _replacement_string_value.keys()) + "]", - re.MULTILINE ) - +_re_string_value = "".join(re.escape(e) for e in _replacement_string_value.keys()) +_re_string_value = re.compile("["+ _re_string_value + "]", re.MULTILINE ) +def _serialize_string_value_match(match): + return _replacement_string_value[match.group(0)] def serialize_string_value(value): - return _re_string_value.sub(lambda match: _replacement_string_value[match.group(0)], value) + return _re_string_value.sub(_serialize_string_value_match, value) def serialize_url(value):