Skip to content

Commit c571fbf

Browse files
committed
Canonicalize historical Script property value names
Assisted-By: GPT-6
1 parent 865a231 commit c571fbf

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ const parseBlocksScriptsProperties = async (type, version) => {
8484
item = String.fromCodePoint(parseInt(item, 16));
8585
} else if (type === 'derived-general-category') {
8686
item = categoryAliases.get(item) || item;
87+
} else if (type === 'scripts') {
88+
// Older Scripts.txt files use names such as LATIN and OLD_ITALIC.
89+
item = looseMatch('Script', item).value;
90+
if (!item) {
91+
throw new Error(`Canonical script name not found in ${line}.`);
92+
}
8793
}
8894
map[item] ??= regenerate();
8995
const rangeParts = charRange.split('-');

‎tests/parsers.mjs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ test('Hangul has pairwise canonical decomposition mappings', async (t) => {
1919
t.assert.equal(await parseDecompositionMapping('1.1.5'), undefined);
2020
});
2121

22+
test('Historical Script values use canonical names', async (t) => {
23+
for (const version of ['3.1.0', '3.1.1', '3.2.0', '4.0.0']) {
24+
const scripts = await parseScripts(version);
25+
t.assert.ok(scripts.Latin.contains(0x41));
26+
t.assert.ok(scripts.Greek.contains(0x3b1));
27+
t.assert.ok(scripts.Inherited.contains(0x300));
28+
t.assert.equal(scripts.LATIN, undefined);
29+
if (version === '3.2.0' || version === '4.0.0') {
30+
t.assert.ok(scripts.Old_Italic.contains(0x10300));
31+
}
32+
}
33+
});
34+
2235
test('Legacy property ranges preserve six-digit code points', async (t) => {
2336
const properties = await parseProperties('3.0.1');
2437
t.assert.ok(properties.Private_Use.contains(0x100000));

0 commit comments

Comments
 (0)