From b183ef39f1d200b7ebb299aece1cc66065eb4729 Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Sat, 24 May 2025 23:58:58 +0200 Subject: [PATCH] fix: parse percentage as unit --- renderer/unit.py | 2 +- test/test_unit.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/renderer/unit.py b/renderer/unit.py index 46f4ffc..86f6c9e 100644 --- a/renderer/unit.py +++ b/renderer/unit.py @@ -44,7 +44,7 @@ class Unit(SpanToken): # Group all units together in a capture group. + "|".join(units) # Word boundary check at end of unit to ensure proper handling of units like A, Ah etc. - + r")\b" + + r")(?!\w)" ) value: str diff --git a/test/test_unit.py b/test/test_unit.py index f37bc09..763aa18 100644 --- a/test/test_unit.py +++ b/test/test_unit.py @@ -41,6 +41,7 @@ def test_special_units_html(): """Test special units: Don't put space before ° and %.""" assertions = { "100%": "100%", + "100 %": "100%", "42,24°": "42,24°", }