Pull request #33: fix: improve unit recognition

Merge in FRAG/50ohm.de from fix/improve-unit-recognition to main

* commit 'b183ef39f1d200b7ebb299aece1cc66065eb4729':
  fix: parse percentage as unit
  fix: improve unit recognition
This commit is contained in:
Tim Grelka DA2TG
2025-06-24 22:04:12 +02:00
committed by Tim Grelka
2 changed files with 9 additions and 1 deletions
+4
View File
@@ -15,6 +15,9 @@ def test_basic_units_html():
"0,75 kW": "0,75 kW",
"33 A": "33 A",
"1 Ah": "1 Ah", # Ah can be a tricky case if the RegEx is wrong, as A might match before Ah, thus rendering the output with an "A" unit
"10 A/mm²": "10 A/mm²",
"DL9MJ": "DL9MJ", # Ensure other strings, like callsings, aren‘t mistaken for units. ;)
"Ein Satz mit 200 V.": "Ein Satz mit 200 V.", # Support units before sentence ends.
}
for input, output in assertions.items():
@@ -38,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°",
}