Skip to content

Commit df8b6c0

Browse files
committed
Canonicalize historical White_space property names
Assisted-By: GPT-6
1 parent 417700a commit df8b6c0

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

‎scripts/parse-blocks-scripts-properties.mjs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ import valueAliases from 'unicode-property-value-aliases';
77
const categoryAliases = valueAliases.get('General_Category');
88
const CODEPOINT_MAX = 0x10ffff;
99

10+
const canonicalPropertyNames = new Map(
11+
[...propertyAliases.values()].map((name) => [name.toLowerCase(), name]),
12+
);
13+
1014
const findCanonicalName = (shortName) => {
11-
const canonicalName = propertyAliases.get(shortName);
15+
const canonicalName =
16+
propertyAliases.get(shortName) ??
17+
canonicalPropertyNames.get(shortName.toLowerCase());
1218
if (!canonicalName) {
1319
return shortName;
1420
}

‎tests/parsers.mjs‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,29 @@ test('Binary property aliases use canonical names', async (t) => {
187187
}
188188
});
189189

190+
test('Historical White_space uses the canonical White_Space name', async (t) => {
191+
for (const version of [
192+
'2.0.14',
193+
'2.1.2',
194+
'2.1.8',
195+
'2.1.9',
196+
'3.0.0',
197+
'3.0.1',
198+
'3.1.0',
199+
'3.1.1',
200+
]) {
201+
const properties = await parseProperties(version);
202+
t.assert.ok(properties.White_Space.contains(0x20));
203+
t.assert.ok(properties.White_Space.contains(0x9));
204+
t.assert.equal(properties.White_space, undefined);
205+
// The legacy Space property is a distinct set, despite its modern alias.
206+
if (properties.Space) {
207+
t.assert.ok(properties.Space.contains(0x20));
208+
t.assert.ok(!properties.Space.contains(0x9));
209+
}
210+
}
211+
});
212+
190213
test('Historical Script values use canonical names', async (t) => {
191214
for (const version of ['3.1.0', '3.1.1', '3.2.0', '4.0.0']) {
192215
const scripts = await parseScripts(version);

0 commit comments

Comments
 (0)