Skip to content

Commit

Permalink
fix(developer): ignore excess whitespace in <row keys> attribute
Browse files Browse the repository at this point in the history
Cherry-pick-of: #12468
Fixes: #12449
  • Loading branch information
mcdurdin committed Oct 10, 2024
1 parent 13c80d5 commit df1ec2f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion developer/src/kmc-ldml/src/compiler/layr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class LayrCompiler extends SectionCompiler {
for (const layer of layers.layer) {
const rows = layer.row.map((row) => {
const erow: LayrRow = {
keys: row.keys.split(' ').map((id) => sections.strs.allocString(id)),
keys: row.keys.trim().split(/[ \t]+/).map((id) => sections.strs.allocString(id)),
};
return erow;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<keyboard3 xmlns="https://schemas.unicode.org/cldr/45/keyboard3" locale="mt" conformsTo="45">
<info name="keys-minimal"/>

<keys>
<key id="grave" output="🪦" />
<key id="mistake" output="oops" />
</keys>

<layers formId="us">
<layer id="base">
<row keys=" grave mistake" />
<row keys=" grave mistake " />
</layer>
</layers>

</keyboard3>
25 changes: 25 additions & 0 deletions developer/src/kmc-ldml/test/test-layr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,30 @@ describe('layr', function () {
]);
},
},
{
subpath: 'sections/layr/row-keys-whitespace.xml',
callback(sect) {
const layr = <Layr> sect;
assert.ok(layr);
assert.equal(compilerTestCallbacks.messages.length, 0);

assert.equal(layr.lists?.length, 1);
const list0 = layr.lists[0];
assert.ok(list0);
assert.equal(list0.layers.length, 1);
assert.equal(list0.hardware.value, 'us');
const layer0 = list0.layers[0];
assert.ok(layer0);
assert.equal(layer0.rows.length, 2);
assert.equal(layer0.id.value, 'base');
assert.equal(layer0.mod, constants.keys_mod_none);
for(const row of layer0.rows) {
assert.ok(row);
assert.equal(row.keys.length, 2);
assert.equal(row.keys[0]?.value, 'grave');
assert.equal(row.keys[1]?.value, 'mistake');
}
},
},
]);
});

0 comments on commit df1ec2f

Please sign in to comment.